Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
echo "Building extended du reports for $1 in $2 ...";
cd $1
du -sh $1/* $1/.[a-zA-Z0-9]* $1/. > $2/du-output.txt
cat $2/du-output.txt | egrep '([0-9]M)' > $2/du-output-MB.txt
cat $2/du-output.txt | egrep '[0-9]G'> $2/du-output-GB.txt
cat $2/du-output-MB.txt | sort -hr > $2/du-output-MB-sorted.txt
cat $2/du-output-GB.txt | sort -hr > $2/du-output-GB-sorted.txt
echo ""
echo '[du extended report]:';
cat $2/du-output-GB-sorted.txt
GBTOTAL=`cat $2/du-output-GB-sorted.txt | perl -pe 's/^(\d+\.+\d+|\d+)\w*.*/$1/g' | paste -sd+ | bc`
echo -ne "GB Total: $GBTOTAL"
echo ""
echo ""
cat $2/du-output-MB-sorted.txt
MBTOTAL=`cat $2/du-output-MB-sorted.txt | perl -pe 's/^(\d+\.+\d+|\d+)\w*.*/$1/g' | paste -sd+ | bc`
echo "MB Total: $MBTOTAL"
echo ""
FULLTOTAL=`echo "scale=2; ($MBTOTAL / 1024) + $GBTOTAL" | bc`
echo "Full Total (GB): $FULLTOTAL"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.