Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if [ -z ${1} ]; then echo "First argument not set";
- else echo "First argument '$1'";
- fi
- if [ -z ${2} ]; then echo "Second argument not set";
- else echo "Second argument '$2'";
- fi
- if [ -z ${3} ]; then echo "Third argument not set";
- else echo "Third argument '$3'";
- fi
- # vytvorenie tmp suboru
- wc -c * 2>/dev/null 1>files.tmp
- FILES=0 # celkovy pocet suborov
- while read line; do
- FILES=$((FILES+1)) # celkovy pocet suborov + 1
- size=$(echo $line | awk {'print $1'})
- if [[ $size -eq 0 ]]; then
- continue
- fi
- if [[ $size -lt 100 ]]; then
- lt100B="${lt100B}#" # <100B
- elif [[ $size -lt 1024 ]]; then
- lt1KiB="${lt1KiB}#" # <1KiB
- elif [[ $size -lt 10240 ]]; then
- lt10KiB="${lt10KiB}#" # <10KiB
- elif [[ $size -lt 102400 ]]; then
- lt100KiB="${lt100KiB}#" # <100KiB
- elif [[ $size -lt 1048576 ]]; then
- lt1MiB="${lt1MiB}#" # <1MiB
- elif [[ $size -lt 10485760 ]]; then
- lt10MiB="${lt10MiB}#" # <10MiB
- elif [[ $size -lt 104857600 ]]; then
- lt100MiB="${lt100MiB}#" # <100MiB
- elif [[ $size -lt 1073741824 ]]; then
- lt1GiB="${lt1GiB}#" # <1GiB
- elif [[ $size -ge 1073741824 ]]; then
- ge1GiB="${ge1GiB}#" # >=1GiB
- fi
- done < files.tmp
- DIRS=0
- for folder in *
- do
- if [ -d "$folder" ];
- then
- echo $file
- DIRS=$((DIRS+1))
- fi
- done
- echo "Root directory: $PWD"
- echo "Directories: $DIRS"
- echo "All files: $FILES"
- echo "File size histogram:"
- echo " <100 B :" $lt100B
- echo " <1 KiB : " $lt1KiB
- echo " <10 KiB :" $lt10KiB
- echo " <100 KiB:" $lt100KiB
- echo " <1 MiB :" $lt1MiB
- echo " <10 MiB :" $lt10MiB
- echo " <100 MiB:" $lt100MiB
- echo " <1 GiB :" $lt1GiB
- echo " >=1 Gib :" $ge1KiB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement