Hire a web Developer and Designer to upgrade and boost your online presence with cutting edge Technologies

Monday, November 28, 2011

Find Sizes of SubDirectories In One Command on Linux

Today, I was running out of disk space on my laptop; not quite unusual to happen. However, with this situation of out of disk, I had to get rid of the directories or files which are using most space and I no longer need.
Now, I can easily find the size of folder by issuing ‘du -skh ’. But this gets tedious if you have 50 folders in one directory. I didn’t want to run same command fifty times. So, I had two options :
  1. Write a script
  2. Or find a command to take care of this situation
A one line command is way better than script any time for me. So, I cooked up an easy to use command:
find * -maxdepth 1 -exec du -skh {} \;
This one line command gave me the size and filename/foldername besides it. Exactly what I wanted. Hope this helps you!

No comments:

Post a Comment