Finding Large IFS Directories
November 8, 2006 Hey, Ted:
The Integrated File System (IFS) continues to grow in importance in our shop. That means it also continues to grow in size. How can we determine which directories are largest when it comes time to clean them up?
Use the Start Qshell (STRQSH or QSH) command to open Qshell. Use cd to navigate to any directory, then try this command.
ls -alsF | grep /$ | sort -r
Clear as mud, huh? Let’s look at it in detail. The ls command lists the files in a directory. In this case, the directory to be listed is the current directory. The following table explains the function of the four switches.
Therefore, the ls command lists the directories directly under the current directory. Each directory name is followed by a slash. Since the file/directory name is the last column in the report, this slash will be the last character on the lines that list a directory name. The first column of each line is the file size in 1K blocks.
Grep looks for lines that end with a slash and passes them along to the sort routine. The dollar sign ($) tells grep that the pattern–in this case, a slash–must match the end of the line. Grep extracts directories only.
Finally the sort utility sorts the list of directories in descending order by the first column, the file size in 1K blocks.
The result looks something like this:
1588 drwxrwsrwx 453 QSYS 0 1626112 Nov 2 10:21 ../ 264 drwxrws--- 10 BR549 0 270336 May 3 2006 ./ 88 drwxrws--- 4 JSMITH 0 90112 Oct 21 2006 ftp/ 80 drwxrwsrwx 3 JSMITH 0 81920 May 25 2005 temp/ 80 drwxrwsrwx 2 JSMITH 0 81920 Sep 18 2005 backup/ 80 drwxrwsrwx 2 JSMITH 0 81920 Mar 18 2006 shelld/ 80 drwxrws--- 2 JSMITH 0 81920 Oct 21 2006 shellb/ 80 drwxrws--- 2 BR549 0 81920 Aug 3 2001 NETDATA/ 72 drwxrwsrwx 2 JSMITH 0 73728 Nov 16 2002 bin/ 72 drwxrws--- 2 BR549 0 73728 Aug 3 2001 WWW/
When it comes to working with the IFS, I find Qshell to be as handy as a pocket!