How to list the size of each file and directory and sort by descending size in Bash?
du -s -- * | sort -n
(this willnot show hidden (.dotfiles) files)
Use du -sm
for Mb units etc. I always use
du -smc -- * | sort -n
because the total line (-c
) will end up at the bottom for obvious reasons :)
PS:
- See comments for handling dotfiles
- I frequently use e.g. 'du -smc /home// | sort -n |tail' to get a feel of where exactly the large bits are sitting