1855770 Members
1809 Online
104103 Solutions
New Discussion

File size?

 
SOLVED
Go to solution
sudhapage
Regular Advisor

File size?

I would like to know which command will show all the filenames in system with size & location in sorted format? (Including mount points) (Only files).

Regards,
Sudhakaran.K
8 REPLIES 8
Steven E. Protter
Exalted Contributor

Re: File size?

Shalom,

Many ways to do this.

ls -la | sort -rn

Gets you biggest to smallest. Add sort commands to get things the way you really want them.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Nagashankarp
Frequent Advisor

Re: File size?

du -sk * | sort -n would give you the size in a ascending order. however if you need only files you can use ll | grep ^- | du -sk * | sort -n
john korterman
Honored Contributor

Re: File size?

Hi,

you can try something like this, which will only list the /tmp directory:

# find /tmp -type f -exec ls -l {} \; |sort -k5n

You should not include too much of the file hierarchy in your search, as it maý consume too many system resources.

regards,
John K.
it would be nice if you always got a second chance
spex
Honored Contributor

Re: File size?

Hi,

Obviously, this will take a while. Even though directories are technically files, I take it you'd like them excluded.

# get listing of all files
find / -local -type f -print | xargs ll > /tmp/filelist
# sort list lexicographically
sort -k9 < /tmp/filelist > /tmp/filelist_sorted_lex
# sort list by size
sort -n -k5 < /tmp/filelist > /tmp/filelist_sorted_size
# remove filelist
rm -f /tmp/filelist

PCS
V.Manoharan
Valued Contributor

Re: File size?

Hi,
this should work for you
1. ll |sort -nr
2. du -sk * |sort -nr
3. du |sort -nr |pg

regards
mano
Bill Hassell
Honored Contributor
Solution

Re: File size?

All files? Are you sure you want more than 30 pages of printing? This one command will do it for you:

ll -R /

but I'm sure that this is not what you really want. A basic HP-UX system has more than 5000 files and directories. They will be sorted in alphabetical order. If you want the files sorted by the modification time, use the command:

ll -Rt /

However, your first question was file size -- so I will assume that you have disk space problems. In thaty case, you do NOT want files sorted by size. You want the mountpoint that is almost full summarized by directory size within the mountpoint. Use du for that task:

du -kx / | sort -rn | head -20
du -kx /var | sort -rn | head -20
du -kx /usr | sort -rn | head -20
du -kx /opt | sort -rn | head -20

Then look at which directories are the largest. Now examin the directory to see why it is so large. Note that bad software will create large directories in / and these should be moved.


Bill Hassell, sysadmin
sudhapage
Regular Advisor

Re: File size?

Hi Thanks to everyone
sudhapage
Regular Advisor

Re: File size?

Thanks