Web Hosting Talk







View Full Version : Show all files in a dir and all sub-dirs sorted by file size?


itomic
02-16-2004, 03:43 AM
Hi All,

Any linux command line gurus out there?

I've got some space issues in my /var dir, and I'm looking for (I presume) a 'du' command that will list all files and filesizes in the /var (AND ALL SUB-DIRECTORIES) directory, sorted by size (largest first).

This command is proving extremely elusive, but would really help me zero-in on the big files that are bloating out...

Thanks in anticipation.

P.S. I don't mind if filesizes are displayed in bytes and not Mbs or Kbs. I don't want to see directories - just files! :-)

SkullOne
02-16-2004, 03:58 AM
First, try this:
man ls

Which would provide this answer:
ls /var/ -alhR --sort=size

man pages will answer 99% of the questions anyone has, if people spent the time researching =/

itomic
02-16-2004, 04:13 AM
Originally posted by SkullOne
First, try this:
man ls

Which would provide this answer:
ls /var/ -alhR --sort=size

man pages will answer 99% of the questions anyone has, if people spent the time researching =/

Thanks for your prompt response. Unfortunately this is not useful because the results are grouped by directory, so comparing file sizes of one directory against another is virtually impossible.

This just came back from IRC:

find . -type f -printf '%s %p \n'|sort -rn|less | more

It seems to be the go, still checking it out...

Brightadmin
02-18-2004, 10:14 PM
Try this,

du -S /var | sort -nr

Regards,

-Bright

itomic
02-19-2004, 02:03 AM
Thanks Brightadmin for the suggestion, but my suggestion above yours appears to give better results.