This question already has an answer here:

The usual ls command can display the size of files with the option -h and I am having a little doubt about it being display in MB or MIB.

For example :

$ ls -lha
drwxr-xr-x 2 user group 4.0K Apr  2 21:49 . 
drwxr-xr-x 5 user group 4.0K Apr  2 21:49 ..
-rw-r--r-- 1 user group 129M Apr  2 21:49 2018-04-02T21:49:08.981976.hdf5

So, this leaves me with 2 questions :

  • Does ls -lha displayed the size in MB or MiB?
  • Is it consistent across Unix-based operating systems and their own versions over time?

N.B.: Not only commercial Unix-based operating systems should be considered for this question.

marked as duplicate by Christopher, Thomas Dickey, Isaac, muru, Hauke Laging Apr 3 '18 at 5:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    I am not asking about the meaning but a subtle difference (which stay "blurry" in these answers's posts) in one option of this command, not to mention whether if this option display is consistent across OSs. – Paradox Apr 2 '18 at 20:41
  • 1
    None of the Q&As pointed to by don_crissti actually answers this question, which is not what the option does, but whether the units are consistent across all implementations and what they are. – JdeBP Apr 3 '18 at 6:21
  • 2
    @JdeBP the question of what the -h flag does in GNU ls, which actually has it, has been adequately answered by the dupe. I don't know how these ls you mention should be "addressed", we can't give a list of all ls implementations, that would be off topic. Paradox, again, please edit your question and clarify what you're asking. The -h option is not standard so yes, it can behave differently or be absent or do something completely different if the authors of an implementation choose it. – terdon Apr 5 '18 at 8:18
  • 1
    Addressing the other ls implementations that exist apart from the GNU one is off-topic? I strongly dispute that. This is Unix and Linux Stack Exchange, not GNU Stack Exchange. – JdeBP Apr 5 '18 at 19:12
  • 1
    @JdeBP of course non-GNU is 100% on topic! What is off topic is asking or providing a long list that attempts to cover all current and past implementations of ls in the *nix world. If Paradox would only edit the question to make it ask something that is specific and answerable about the portability of -h, then it would absolutely be on topic. But asking for the existence and behavior of the -h flag on every ls in existence is just too broad for this site. – terdon Apr 6 '18 at 10:24

From the ls manpage:

-h, --human-readable
         with -l and -s, print sizes like 1K 234M 2G etc.
--si   likewise, but use powers of 1000 not 1024

So if you just use -h you will get MiB (^1024). If you add --si to the options, it will use MB (^1000). Verified on ubuntu, debian, and redhat. I don't have access to any commercial UNIX operating systems at the moment, but out of the box they tend not to include a -h option.

  • "but out of the box they tend not to include a -h option" From my experience, it is exactly the opposite (Fedora, Manjaro, Debian, Ubuntu and Scientific Linux) ; maybe you meant something else? – Paradox Apr 2 '18 at 20:43
  • None of those are commercial Unices. Although M. McMahon could at least have looked at the BSDs. – JdeBP Apr 2 '18 at 20:51
  • @JdeBP This option was available on the version of RHEL 6/7 I had been using in the past. (BTW Scientific Linux is based on it). But, still, I do not see the point : are "commercial Unices" universally lacking this option? – Paradox Apr 2 '18 at 20:57
  • Solaris has it, not AIX or HPUX. I recall answering this, but don't see it readily. – Thomas Dickey Apr 2 '18 at 21:26
  • 1
    @ThomasDickey - unix.stackexchange.com/a/302681/22142 – don_crissti Apr 2 '18 at 21:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.