Skip to content

Instantly share code, notes, and snippets.

@trankimvu
Last active June 25, 2018 02:16
Show Gist options
  • Save trankimvu/3166913abdaf4bbe795a283ef82d82b6 to your computer and use it in GitHub Desktop.
Save trankimvu/3166913abdaf4bbe795a283ef82d82b6 to your computer and use it in GitHub Desktop.
How to list files from n biggest directories?
#https://askubuntu.com/questions/898104/how-to-list-files-from-n-biggest-directories
du -hs */ | sort -rh | head -5 | while read -r size dir ; do echo "$dir"; ls -lha "$dir"; done
#accepted
#There are two types of file access that use disk space, but don't show up with your tools: deleted (but still open) files, and files being written to.
#I have these two aliases defined that I find very useful:
# from http://www.certpal.com/blogs/2010/12/find-open-files-in-linux-using-lsof/
alias bigopenfiles="sudo lsof / | awk '{if(\$7 > 1048576) print \$7/1048576 \"MB\" \" \" \$9 }' | sort -n -u"
alias deletedfiles="sudo lsof / | egrep 'PID|\(deleted\)'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment