Created
April 1, 2017 20:10
-
-
Save fletcherist/c91c96c2cce970dd359e3a43872b7728 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dus () { | |
size=0 | |
# checking whether the dir argument provided | |
if [ "$1" != "" ]; then | |
sub_dir="/$1" | |
else | |
sub_dir="" | |
fi | |
# iterating over all files in all subdirectories | |
for f in $PWD$sub_dir/**/* | |
do | |
# checking whether that's the path to the file | |
if [[ -f $f ]]; then | |
# calculating size in bytes | |
tmp=`wc -c "$f" | awk '{print $1}'` | |
((size+=tmp)) | |
fi | |
done | |
echo "$size" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment