Tuesday, November 16, 2010

Finding large files works in AIX, Unix and Linux.

find / -type f -size +10000 -exec ls -lrt {} \; | sort -n +4

You can change "/" or "." or "/home" ....

Use the -xdev option of find so as not to traverse devices...

find / -xdev -type f -size +10000 -print | xargs du -ka | sort -rn

Sometimes use du -kx|sort -n

On linux, following is the possible command:
find / -type f -size +20000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

To tweak the output and have the file sizes in a column, add this to the end:

| column -t

this just expands the tabs to even the columns out.

Finding all large directories
To find all directories taking 50k (kilobytes) blocks of space. This is useful to find out which directories on system taking lot of space.
# find / -type d -size +50k
Output:

/var/lib/dpkg/info
/var/log/ksymoops
/usr/share/doc/HOWTO/en-html
/usr/share/man/man3

Type following on your linux command prompt:

find / -size +10240000c -exec du -h {} \;
That should find all files larger then ~10MB.

No comments:

Post a Comment

Followers