Display File Size in KB, MB or GB In Linux

Linux Do you want to display file size in typical file formats such as KBMB or GB in Linux? What you actually want is to display them in human readable format.

By default, doing an ls command or ls -la lists files and their sizes in byte format. Now, that isn't so helpful is it? What you need to do is add "h" or the human readable format option. Let's take a look at the description straight from the man page.



So using this for example, issuing a command ls -lah would give you the following output:



instead of...



Now that makes you forget that 1024 bytes = 1kb. Did this help you? Please leave a comment!

2 comments ON Display File Size in KB, MB or GB In Linux

September 2, 2012 at 5:39 AM Sean said...

i am trying to pull the available memory for my system in MB, i cannot get it to work because 'top' seems to change the units to make them "human readable" is there a way to force the units to be always read out in MB?

September 2, 2012 at 3:40 PM twthwtech said...

Did you mean top as in this one?


http://manpages.ubuntu.com/manpages/lucid/man1/top.1.html


I'm not sure if I understand or maybe I just don't know.

Post a Comment