Kwissle

My real-time quiz battle game Kwissle.com

Crosstips.org

My fun Crossword solver project. Crosstips.org & Krysstips.se

Kung Fu

Fujian White Crane Kung Fu

Photos

Photoalbum, both old and new.

Twitter

Follow me on Twitter

Contact me

My contact details and how to contact me.

 

KungFuPeople.com
Do you train Kung Fu?
Or know someone who does?
Then check out KungFuPeople.com


Mobile version of this page Mobile version of this page


 
Linux

Linux tip: du --max-depth=1


27th of September 2007

There are lots of fancy programs for Linux to find out where your gigabytes are sitting and filling your hard drive, the simplest of them is du (from disk usage). The trick is to use the --max-depth=1 option so that you get a view of which folder weighs how much. Try this:

 peterbe@trillian:~/tmp $ du -h --max-depth=1
 900K    ./Example-Receipts
 4.0K    ./Foredettinghelgen
 44K     ./IssueTrackerBlogInterface
 1.9M    ./IssueTrackerProduct
 12K     ./fried-mugshots
 2.1M    ./ies4linux-2.0.5
 4.8M    ./pyexcelerator
 52K     ./levenstein
 4.0K    ./newitpdesign
 4.7M    ./photoresizing
 69M     ./databases
 4.5M    ./i18nextract-sa
 532M    .

Pretty nifty! That way you can quickly see which folder contains the most junk so that you can free up some hard drive space.

To sort it I don't know how to reformat it into human readable values but there's the command:

 peterbe@trillian:~/tmp $ du --max-depth=1 | sort -n
 4       ./Foredettinghelgen
 4       ./newitpdesign
 12      ./fried-mugshots
 44      ./IssueTrackerBlogInterface
 52      ./levenstein
 900     ./Example-Receipts
 1856    ./IssueTrackerProduct
 2140    ./ies4linux-2.0.5
 4528    ./i18nextract-sa
 4796    ./photoresizing
 4872    ./pyexcelerator
 70392   ./databases
 544608  .



Comment

Anonymous - 18th December 2007  [«« Reply to this]
You can use -h option for human readable values. (i assume the convertion of bytes to Megabytes, kilobytes etc is what you by human readable values, )
du -h --max-depth=1.

Comment for a very old post... Came across ur site while i was googling for something.

- SS
 
Name:
Email:
hide my email address.

Your email address will be encoded to prevent email-extraction spiders from reading it so you won't get spammed if you decide to show your email address.