Sometimes we want to see the sizes of files as returned by the ls command displayed in some reasonable format or in other words in human readable presentation.
To display the file sizes in units like 7K, 5M, 8.2G, etc… use the -lh option with ls.
Note that -h is a GNU coreutils extension.
To display the sizes rounded up to the nearest MiB (2^20 bytes), you should use the command :
ls -l –block-size=M
If the M suffix bothers you in some way, you can get rid of it by using –block-size=1M.
file size linux
If however you want to see the size in MB (10^6 bytes) instead, you should use the command with the option –block-size=MB.
For more on this, you may want to visit the man page for ls.
Simply type in man ls and look up the word SIZE. In case you are interested, you will find other units as well (besides MB/MiB).
If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.