I would like to find out what were top consuming files or folders in linux, which consumes most space (in human readable form - in MB or in GB) files or folders should be recently modified - for example within last month.
I suspect this is combination of du -exec, sort, ls command, but can be specify which ?
Top consuming files modified within last month:
find "$PWD" -type f -mtime -30 -exec du -sh '{}' + | sort -rh | head
Top consuming folders modified within last month:
find "$PWD" -type d -mtime -30 -exec du -sh '{}' + | sort -rh | head
If your sort
version doesn't support the -h
option, you can try:
find "$PWD" -type f -mtime -30 -exec du -s '{}' + | sort -nr | head | cut -f2- | xargs -d'\n' du -sh