Initial import from 0.5a version.
[secure-linux-project.git] / encrypt / sizes.sh
1 #!/bin/sh
2 ##############################################
3 # Script for Secure Linux Project            #
4 # Copyright(c) 2005, 2006 by Roland Haeder   #
5 ##############################################
6 # Purpose: Determines sizes of single files  #
7 #          or of a whole bunch of files in a #
8 #          directory                         #
9 ##############################################
10 # This software is licensed under the GNU    #
11 # General Public License Version 2 or either #
12 # and comes with ABSOLUTELY NO WARRANTY      #
13 # neither implied nor explicit.              #
14 ##############################################
15
16 if test "$1" == ""; then
17         echo "$0: No directory provided for scanning!"
18         exit 6
19 fi
20
21 cd /
22 DIR="$1"
23 # use only first entry
24 DIR=`echo $DIR | cut -f 1 -d " "`
25 echo -n "$0: Reading sizes in /$DIR ... "
26 SIZES=`find $DIR -exec stat --format="%s" {} \;`
27 echo "done"
28 TOTAL=0
29
30 echo -n "$0: Calculating... "
31 for si in $SIZES; do
32         TOTAL="$(($TOTAL + $si))"
33 done
34 export TOTAL
35 echo "done"
36 echo
37 echo "Total size: $(($TOTAL/1024/1024/1024)) GByte"