Last active
March 5, 2019 00:53
-
-
Save jbobbylopez/257f3cbc03cd358e246abf13124ceccd to your computer and use it in GitHub Desktop.
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 characters
#!/bin/bash | |
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