Skip to content

Instantly share code, notes, and snippets.

@brianoflan
Last active December 16, 2016 17:36
Show Gist options
  • Save brianoflan/f53ba3f5f74e572ac3b120f0cc7074c8 to your computer and use it in GitHub Desktop.
Save brianoflan/f53ba3f5f74e572ac3b120f0cc7074c8 to your computer and use it in GitHub Desktop.
Which folder is most full? (ls_fullest, df, du, df -h, du -ks)
#!/bin/bash
ls_fullest() {
ls -a | egrep -v '^[.][.]?$' | while read e ; do x=`df -h "$e" | tail -1 | awk '{print $NF}'` ; [[ "$x" == "$tgt" ]] && sudo du -ks "$e" 2>/dev/null ; done | sort -n -k 1 | tail
}
tgt='/var' ;
cd "$tgt" ;
ls_fullest ;
cd someBigFolder ;
ls_fullest ;
# (Repeat....)
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment