Operating System - HP-UX
1829666 Members
9536 Online
109992 Solutions
New Discussion

Re: ls (is the result in bytes)

 
SOLVED
Go to solution
OldSchool
Honored Contributor

Re: ls (is the result in bytes)

kb -> mb divide by 1024, not 1000
OldSchool
Honored Contributor

Re: ls (is the result in bytes)

101367 / 1024 = 99.25488....
Avinash20
Honored Contributor

Re: ls (is the result in bytes)

1 MB = 1024 Kb
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
Patrick Wallek
Honored Contributor

Re: ls (is the result in bytes)

>>kb -> mb divide by 1024, not 1000

Technically speaking now, that is incorrect.

The terminology has been changed by the IEEE in 1998, though it is not common knowledge.

The KB, MB, GB, etc. values are now technically base 10 values. 1 GB = 1000 bytes, 1 MB = 1000 KB, 1 GB = 1000 MB.

The base 2 (binary) values that most of us are used to using are now technically the kibibyte (KiB), mebibyte (MiB), gibibyte (GiB), tebibyte (TiB), etc. So 1024 bytes = 1 KiB, 1024 KiB = 1 MiB, 1024 MiB = 1 GiB, etc.

For more information see:
http://en.wikipedia.org/wiki/MiB

Avinash20
Honored Contributor

Re: ls (is the result in bytes)

So in that case,

# ls -l |awk '/^d/ {print $NF}'|xargs du -ks|awk '{printf "%6.2f %s\n",$1/1000,$2}'

will give the output in Mb
where
1MB = 1000Kb

Thanks to James and Patrick..
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
OldSchool
Honored Contributor

Re: ls (is the result in bytes)

patrick: is was aware of the change, but as you noted its not common knowledge...so I used the more common usage....

as to the IEEE and the redefinition of KB, MB, and GB...IMHO, they should should have continued to use the old terminology w/ the old values, and used the new terminology w/ the "new" names (KiB, MiB....)....after all, "anything that changes form, fit or function requires a new part number"

but that's just me...and i'm grumpy
Manuales
Super Advisor

Re: ls (is the result in bytes)

THANKS A LOT ALL FOR YOUR GREAT HELP AND SUPPORT !!!!! HAVE A NICE WEEKEND :)
Court Campbell
Honored Contributor

Re: ls (is the result in bytes)

This is a really long thread for a simple fix. You could just install coreutils.

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

Then run ls from the coreutils bin directory with the -h (human-readbale) switch.





"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???"
James R. Ferguson
Acclaimed Contributor

Re: ls (is the result in bytes)

Hi:

> Court: This is a really long thread for a simple fix. You could just install coreutils.

Agreed, but then Manuales wouldn't have learned so much as he has :-}

Regards!

...JRF...

OldSchool
Honored Contributor

Re: ls (is the result in bytes)

besides...it would start the whole issue w/ the math again. (although it appears it may use the "new" definitions)

from a linux "du" man page, regarding the "-h" or "--human-readable" option:

SIZE may be (or may be an integer optionally followed by) one of the following:

kB 1000, K 1024, MB 1000*1000,
M 1024*1024, and so on for....
G, T, P, E, Z, Y.

it's friday, it's getting late, and I don't want to think about Mib -vs- MB any more...