Hi!
I'm using Unix HP
I'm looking for a command which find the 20 (less or more) biggest files on / but which exclude every other files system
Thanks;)
Hi!
I'm using Unix HP
I'm looking for a command which find the 20 (less or more) biggest files on / but which exclude every other files system
Thanks;)
You'll have to find all files on the root device, telling find to exclude other mounted filesystems, and have it report the size in a common format (eg. in kilobytes). Then you can sort that output in reverse, and have head display the first 20 lines. Or, in code:
find / -xdev -type f -exec du -ks {} \; | sort -nr | head -20
A faster approach, without executing an external program over and over, would be
find / -xdev -type f -ls | sort +6nr -7 | head -20
On Linux, yes. On HP-UX (as the OP stated) it won't work as that find doesn't understand the -ls switch.
You're right.
Thanks hergp and pludi for your help
The -ls switch is not only available on Linux but also on Solaris. If HP-UX doesn't understand it then you still can reduce the number of executions of du (in my testdrive on Solaris by factor 40) using
find / -xdev -type f | xargs du -k | sort +0rn -1 | head -20
The hergp looks ok but fails on HP-UX when filenames contains spaces.
This visually inefficient method gives the correct answer very quickly.
find // -xdev -type f -size +1000000c -exec ls -lad {} \;| \
awk '{print $5,$9}'|sort -n -r|head -20
If you have less than 20 files larger than 1,000,000 bytes then reduce the constant!
Works anywhere, but less efficient. Replace / with any mountpoint you want.
find / -type f -xdev -size +1000000c -exec ls -s {} \; | sort -rn | head -20