Does option “-h” for “ls” display size in MB or MiB and is it consistent over Unix-based systems? [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-1
down vote

favorite













This question already has an answer here:



  • meaning of -h in ls command

    1 answer



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.







share|improve this question














marked as duplicate by Christopher, Thomas Dickey, Isaac, muru, Hauke Laging Apr 3 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 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 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 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 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 at 10:24














up vote
-1
down vote

favorite













This question already has an answer here:



  • meaning of -h in ls command

    1 answer



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.







share|improve this question














marked as duplicate by Christopher, Thomas Dickey, Isaac, muru, Hauke Laging Apr 3 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 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 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 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 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 at 10:24












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite












This question already has an answer here:



  • meaning of -h in ls command

    1 answer



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.







share|improve this question















This question already has an answer here:



  • meaning of -h in ls command

    1 answer



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.





This question already has an answer here:



  • meaning of -h in ls command

    1 answer









share|improve this question













share|improve this question




share|improve this question








edited Apr 3 at 13:25

























asked Apr 2 at 20:15









Paradox

1267




1267




marked as duplicate by Christopher, Thomas Dickey, Isaac, muru, Hauke Laging Apr 3 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.






marked as duplicate by Christopher, Thomas Dickey, Isaac, muru, Hauke Laging Apr 3 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 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 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 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 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 at 10:24












  • 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 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 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 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 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 at 10:24







1




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 at 20:41




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 at 20:41




1




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 at 6:21




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 at 6:21




2




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 at 8:18




@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 at 8:18




1




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 at 19:12





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 at 19:12





1




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 at 10:24




@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 at 10:24










1 Answer
1






active

oldest

votes

















up vote
2
down vote













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.






share|improve this answer




















  • "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 at 20:43










  • None of those are commercial Unices. Although M. McMahon could at least have looked at the BSDs.
    – JdeBP
    Apr 2 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 at 20:57










  • Solaris has it, not AIX or HPUX. I recall answering this, but don't see it readily.
    – Thomas Dickey
    Apr 2 at 21:26






  • 1




    @ThomasDickey - unix.stackexchange.com/a/302681/22142
    – don_crissti
    Apr 2 at 21:32

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote













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.






share|improve this answer




















  • "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 at 20:43










  • None of those are commercial Unices. Although M. McMahon could at least have looked at the BSDs.
    – JdeBP
    Apr 2 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 at 20:57










  • Solaris has it, not AIX or HPUX. I recall answering this, but don't see it readily.
    – Thomas Dickey
    Apr 2 at 21:26






  • 1




    @ThomasDickey - unix.stackexchange.com/a/302681/22142
    – don_crissti
    Apr 2 at 21:32














up vote
2
down vote













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.






share|improve this answer




















  • "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 at 20:43










  • None of those are commercial Unices. Although M. McMahon could at least have looked at the BSDs.
    – JdeBP
    Apr 2 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 at 20:57










  • Solaris has it, not AIX or HPUX. I recall answering this, but don't see it readily.
    – Thomas Dickey
    Apr 2 at 21:26






  • 1




    @ThomasDickey - unix.stackexchange.com/a/302681/22142
    – don_crissti
    Apr 2 at 21:32












up vote
2
down vote










up vote
2
down vote









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.






share|improve this answer












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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 2 at 20:26









Ben McMahon

235




235











  • "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 at 20:43










  • None of those are commercial Unices. Although M. McMahon could at least have looked at the BSDs.
    – JdeBP
    Apr 2 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 at 20:57










  • Solaris has it, not AIX or HPUX. I recall answering this, but don't see it readily.
    – Thomas Dickey
    Apr 2 at 21:26






  • 1




    @ThomasDickey - unix.stackexchange.com/a/302681/22142
    – don_crissti
    Apr 2 at 21:32
















  • "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 at 20:43










  • None of those are commercial Unices. Although M. McMahon could at least have looked at the BSDs.
    – JdeBP
    Apr 2 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 at 20:57










  • Solaris has it, not AIX or HPUX. I recall answering this, but don't see it readily.
    – Thomas Dickey
    Apr 2 at 21:26






  • 1




    @ThomasDickey - unix.stackexchange.com/a/302681/22142
    – don_crissti
    Apr 2 at 21:32















"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 at 20:43




"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 at 20:43












None of those are commercial Unices. Although M. McMahon could at least have looked at the BSDs.
– JdeBP
Apr 2 at 20:51





None of those are commercial Unices. Although M. McMahon could at least have looked at the BSDs.
– JdeBP
Apr 2 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 at 20:57




@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 at 20:57












Solaris has it, not AIX or HPUX. I recall answering this, but don't see it readily.
– Thomas Dickey
Apr 2 at 21:26




Solaris has it, not AIX or HPUX. I recall answering this, but don't see it readily.
– Thomas Dickey
Apr 2 at 21:26




1




1




@ThomasDickey - unix.stackexchange.com/a/302681/22142
– don_crissti
Apr 2 at 21:32




@ThomasDickey - unix.stackexchange.com/a/302681/22142
– don_crissti
Apr 2 at 21:32


Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay