Operating System - HP-UX
1748251 Members
3567 Online
108760 Solutions
New Discussion юеВ

Seeing file size in Megs by using command ll or ls -lrt and pipe filter

 
SOLVED
Go to solution
Shivkumar
Super Advisor

Seeing file size in Megs by using command ll or ls -lrt and pipe filter

Hi,

I need to see file size and directory size (including its subdirectories)
in MegaByte or GigaByte while executing the command ll or ls -lrt.

Can anyone let me know the option to use after ll or ls -lrt by using
pipe (|) filter ?

Thanks,
Shiv
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor
Solution

Re: Seeing file size in Megs by using command ll or ls -lrt and pipe filter

Hi SHiv:

For megabytes:

# ls -l /tmp|awk '{$5=sprintf("%6.2f",$5/1024/1024);print}'

For gigabytes:

ls -l /tmp|awk '{$5=sprintf("%6.2f",$5/1024/1024/1024);print}'

Regards!

...JRF...
Court Campbell
Honored Contributor

Re: Seeing file size in Megs by using command ll or ls -lrt and pipe filter

Install coreutils.

http://hpux.connect.org.uk/hppd/hpux/Gnu/coreutils-7.4/

It has the GNU version of ls. You can use the -h (human-readable) option to get the sizes in Megs, Gigs, etc.
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
Court Campbell
Honored Contributor

Re: Seeing file size in Megs by using command ll or ls -lrt and pipe filter

I guess I should also mention that you will want to add /usr/local/coreutils/bin to your PATH variable before /bin. Otherwise you will still be using the sysV/bsd style ls.
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"