Thursday 23 May 2013

Directory size listing

A lot of times when freeing up disk space [Well yes in today's world also people like me need to do it.], instead of opening my file manager and finding the size of the folders by checking the properties section in the right-click drop-down, I wanted to look at a list view where I can sort by folder size. Now, KDE's Dolphin file manager shows number of items within a folder but not the size and I anyways prefer the command line so I wanted a command line tool that lists size of directories. The amount of space left on the partitions can be easily found by the following command:

df -h

I also found a command for directory size.

du

However, its default behaviour is to show the size of files recursively. So, I do not get the size of the folders in the directory I am interested in. Instead, I get the size of files within those folders and recursively so forth. I needed to set the depth of search into the folders. I found a parameter with a similar name. The following command works just as I need.

du --max-depth=1 -h

No comments: