1832526 Members
8384 Online
110043 Solutions
New Discussion

List files by size

 
Marcelo Muzilli_1
Occasional Contributor

List files by size

Hi all,

what is the command in HP-UX that I can list a diretory by size?

I know that Linux its possible using the command:
ls -ls

How can I do this in HP-UX?

Regards,

Marcelo Muzilli
9 REPLIES 9
Armin Feller
Honored Contributor

Re: List files by size

# ll

or

# ll -d


Regards,
Armin
Pete Randall
Outstanding Contributor

Re: List files by size

How about

ll |sort -k 5

Pete

Pete
Armin Feller
Honored Contributor

Re: List files by size

# du

or

# du -r

see also
# man du
Christopher McCray_1
Honored Contributor

Re: List files by size

Hello,

Or how about

# du -ks *|sort -rn

Chris
It wasn't me!!!!
Chuck J
Valued Contributor

Re: List files by size

# ls -l | sort -k 5
Marcelo Muzilli_1
Occasional Contributor

Re: List files by size

I tried the command below and look the result:

# ls -l | sort -k 5

total 90
lr-xr-xr-t 1 root sys 8 Oct 24 17:19 bin -> /usr/bin
lr-xr-xr-t 1 root sys 8 Oct 24 17:19 lib -> /usr/lib
drwxr-xr-x 2 root sys 96 Nov 1 07:35 snap
drwxr-xr-x 2 root sys 96 Oct 25 08:58 cdrom2
drwxr-xr-x 3 root sys 96 Oct 25 09:07 .sw
drwxr-xr-x 3 root sys 96 Oct 25 11:40 bmpdb
drwxrwxr-x 2 root sys 96 Oct 28 09:20 cdrom
-rw------- 1 root sys 98 Dec 20 10:32 .Xauthority
-rw------- 1 root sys 108 Dec 9 14:51 .sh_history
-rw------- 1 root sys 179 Oct 29 08:15 nohup.out
drwxr-xr-x 2 root root 96 Oct 24 16:08 lost+found
dr-xr-xr-x 2 root root 96 Oct 24 17:39 tmp_mnt
drwxr-xr-x 3 root root 96 Oct 25 11:39 home
-r--r--r-- 1 bin bin 1014 Nov 27 11:38 .profile
drwxr-xr-x 11 root sys 1024 Dec 20 10:32 .dt
drwxr-xr-x 4 root sys 1024 Nov 1 07:35 online_backup
drwxr-x--- 2 root sys 1024 Nov 25 12:06 gcc
dr-xr-xr-x 25 bin bin 1024 Nov 27 11:14 opt
dr-xr-xr-x 23 bin bin 1024 Oct 24 17:19 usr
dr-xr-xr-x 18 bin bin 1024 Oct 24 17:32 var
dr-xr-xr-x 6 bin bin 1024 Oct 25 12:39 stand
-rw-r--r-- 1 root sys 2040 Dec 20 10:34 txt.txt
-rw------- 1 root sys 2861 Dec 20 10:32 .ICEauthority
dr-xr-xr-x 12 bin bin 3072 Oct 25 12:43 sbin
dr-xr-xr-x 15 bin bin 4096 Dec 9 09:48 dev
dr-xr-xr-x 1 root root 512 Dec 9 09:48 net
-rwxr-xr-x 1 root sys 5452 Oct 25 06:43 .dtprofile
dr-xr-xr-x 23 bin bin 6144 Dec 10 15:36 etc
drwxrwxrwx 50 bin bin 7168 Dec 20 10:47 tmp
drwxr-xr-x 7 root root 1024 Dec 10 15:36 mnta2
drwxr-xr-x 15 root root 1024 Oct 31 15:37 mnta1

The question is: why the /net directory is after /dev directory (4096 is greater than 512) ?

Regards,

Muzilli
Chris Wilshaw
Honored Contributor

Re: List files by size

You'll actually need

ll | sort -nk 5

This treats field 5 (file size) as being purely numeric. Just using -k 5 will mean that it treats it as a character string, so anything starting with 4 is dispalyed before things starting with 5.
Marcelo Muzilli_1
Occasional Contributor

Re: List files by size

Thank you.... it's working with

ll | sort -nk 5

Cheers,

Marcelo Muzilli
Pete Randall
Outstanding Contributor

Re: List files by size

Thanks for straightening that out, Chris. I know better - I even tested it, but didn't notice the anomalies.

Pete

Pete