Sometimes, we want to see disk usage in a human readable form (KB, MB, GB) for each subdirectory.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[ytyoun@ladon: ~]# find . -maxdepth 1 -type d -exec du -sh {} \; | sort -h
4.0K    ./nsmail
8.0K    ./Downloads
8.0K    ./.eggcups
8.0K    ./.gnome2_private
8.0K    ./.gvfs
 
...
 
120M    ./.mozilla
186M    ./emacs-24.2
223M    ./.cache
240M    ./Desktop
284M    ./Work
444M    ./.config
1.9G    .

How it works.

  1. find: a linux command to search for files or directories in a directory hierarchy.
  2. find .: runs the find command on the current directory
  3. find . -maxdepth 1 -type d: searches for all the directories contained in the current directory without descending to subdirectories below the current directory
  4. find (condition) -exec (command) {} \;: for each file or directory satisfied by the (condition), run (command).
    {} \; is replaced by each directory satisfied by the find command.
  5. du -sh (dir): displays the disk usage statistics of the directory (dir) in a human readable form.
    In this example, we just feed {} \; as we want to run du command for each directory obtained by the find command.
  6. | : linux pipe
  7. sort -h: sorts the human readable numbers such as KB, MB and GB.
Comments Off on Check which directories hold too much space

PDFnup

1
pdfnup doc.pdf --frame true --scale 0.9 --nup 1x2 --delta "0.2cm 0.3cm"
Comments Off on PDFnup