Skip to content

Instantly share code, notes, and snippets.

@tavy315
Last active October 7, 2016 08:27
Show Gist options
  • Save tavy315/54d4e6b2023dee87f1c8af097dc41b5c to your computer and use it in GitHub Desktop.
Save tavy315/54d4e6b2023dee87f1c8af097dc41b5c to your computer and use it in GitHub Desktop.
#! /bin/bash
if [ "$1" == "" ]
then
echo -e -n "\E[36mUsage:\E[32m ./`basename $0` \E[33mdirectory \E[0m"
echo ""
exit
fi
c=0
du $1 2> /dev/null | sort -nr -k1 | head -20 | cut -f2 | while read fname
do
if [ $(($c%2)) -eq 0 ]
then
printf "\E[0;32m`du -h --summarize \"$fname\" 2> /dev/null | cut -f1`\t\E[1;32m${fname}\E[0m\n"
else
printf "\E[0;33m`du -h --summarize \"$fname\" 2> /dev/null | cut -f1`\t\E[1;33m${fname}\E[0m\n"
fi
c=$(($c+1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment