Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2arunpmohan/30a6c19b2bce387ec8626353589e0170 to your computer and use it in GitHub Desktop.
Save 2arunpmohan/30a6c19b2bce387ec8626353589e0170 to your computer and use it in GitHub Desktop.

Size of all the directories, files etc in the current directory in human-readable format.

du -sh *

command to know the free space in the disk:

df -h .

https://unix.stackexchange.com/a/185777

find the size of specific set of files

du -ch /var/log/elasticsearch/elasticsearch-2017-08-2*.log | grep total

to find the size of directories and files

du -h *

For finding the files by size

find -type f -exec du -Sh {} + | sort -rh | head -n 5

How to remove folders with a certain name

find -type d -name a -exec rm -rf {} ;

eg: if from a folder having multiple projects, you want to remove all the "node_modules" folder, use the command as below:

find -type d -name node_modules -exec rm -rf {} ;

the first part of this command (ie up to "find -type d -name node_modules" will show all the paths to the node_modules). then the second part of the command (exec rm -rf {} ;) will remove those folders

more in the below link: https://stackoverflow.com/questions/13032701/how-to-remove-folders-with-a-certain-name

For finding the files by size

find -type f -exec du -Sh {} + | sort -rh | head -n 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment