Created
April 1, 2017 20:10
-
-
Save fletcherist/c91c96c2cce970dd359e3a43872b7728 to your computer and use it in GitHub Desktop.
Revisions
-
fletcherist created this gist
Apr 1, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ #!/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" }