Monday, July 28, 2008

Finding the Largest and the Smallest File in a Directory

1. In order to find 9 largest files in a directory (say /etc),
please give following command:
$ ls -lS /etc | head

total 2816
-rw-r--r-- 1 root root 600399 2008-07-28 10:11 prelink.cache
-rw-r--r-- 1 root root 362047 2007-04-18 14:10 services
-rw-r--r-- 1 root root 144190 2007-10-12 15:08 lynx.cfg
-rw-r--r-- 1 root root 122098 2008-07-25 10:47 ld.so.cache
-rw-r--r-- 1 root root 117276 2007-09-17 17:57 Muttrc
-rw-r--r-- 1 root root 114765 2007-10-11 01:28 gwen-public-ca.crt
-rw-r--r-- 1 root root 84649 2007-08-23 12:54 sensors.conf
-rw-r--r-- 1 root root 44990 2007-10-16 18:50 php.ini
-rw-r--r-- 1 root root 31274 2007-10-09 14:33 jwhois.conf

2. In order to find 9 smallest files in a directory (say /etc),
please give following command:

$ ls -lSr /etc | head
total 2816
-rw-r--r-- 1 root root 0 2007-08-03 06:09 odbc.ini
-rw-r--r-- 1 root root 0 2000-01-13 04:48 motd
-rw-r--r-- 1 root root 0 2000-01-13 04:48 exports
-rw-r--r-- 1 root root 0 2007-08-16 19:23 environment
-rw-rw-r-- 1 root disk 0 2007-08-22 17:15 dumpdates
-rw-r--r-- 1 root root 0 2007-09-24 19:28 cron.deny
-rw------- 1 root root 1 2007-10-05 17:41 at.deny
lrwxrwxrwx 1 root root 7 2008-07-18 03:26 rc -> rc.d/rc
lrwxrwxrwx 1 root root 10 2008-07-18 03:26 rc6.d -> rc.d/rc6.d

No comments: