Finding the smallest or the largest files and directories

To list the contents of a directory with the smallest files first, use ls with both the `−S' and `−r' options, which reverses the sorting order of the listing.

To list the files in the current directory and their attributes, sorted from smallest to largest, type: $ ls −lSr RET

Finding the Smallest Directories

To output a list of directories sorted by their size−−the size of all the files they contain−−use du and sort. The du tool outputs directories in ascending order with the smallest first; the `−S' option puts the size in kilobytes of each directory in the first column of output. Give the directory tree you want to output as an option, and pipe the output to sort with the `−n' option, which sorts its input numerically. · To output a list of the subdirectories of the current directory tree, sorted in ascending order by size, type:

$ du −S . | sort −n RET

Finding the Largest Directories

Use the `−r' option with sort to reverse the listing and output the largest directories first. To output a list of the subdirectories in the current directory tree, sorted in descending order by size, type:

$ du −S . | sort −nr RET

To output a list of the subdirectories in the `/usr/local' directory tree, sorted in descending order by size, type:

$ du −S /usr/local | sort −nr RET

Posted on: 16/12/2009








0 Comments
If you want to leave a comment please Login or Register
How to backup your data using rsync......
Understanding autoconf......
The Basics of fdisk......
Accessing Memory Using DMA......
The fd Directory......