Friday, 22 June 2012

Disk usage - du

Usage

du takes a single argument, specifying a pathname for du to work; if it is not specified, the current directory is used. The SUS mandates for du the following options:
-a, display an entry for each file (and not directory) contained in the current directory
-H, calculate disk usage for link references specified on the command line
-k, show sizes as multiples of 1024 bytes, not 512-byte
-L, calculate disk usage for link references anywhere
-s, report only the sum of the usage in the current directory, not for each file
-x, only traverse files and directories on the device on which the pathname argument is specified.

Sum of directories in kilobytes:
 $ du -sk *
 152304  directoryOne
 1856548 directoryTwo
Sum of directories in human-readable format (Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte):
 $ du -sh *
 149M directoryOne
 1.8G directoryTwo
disk usage of all subdirectories and files including hidden files within the current directory (sorted by filesize) :
 $ du -sk .[!.]* *| sort -n
disk usage of all subdirectories and files including hidden files within the current directory (sorted by reverse filesize) :
 $ du -sk .[!.]* *| sort -nr
The weight of directories:
 $ du -d 1 -c -h

No comments:

Post a Comment