Counting digits in the file sizes output by ls -l is not fun

-rw-r--r-- 1 bear bear 1062608896 Feb 17 19:47 Stocks.db
-rw-r--r-- 1 bear bear         16 Feb 17 20:06 word

However, the alternative, using --block-size=MB yields deceptively large file sizes for small files

-rw-r--r-- 1 bear bear 1063MB Feb 17 19:47 Stocks.db
-rw-r--r-- 1 bear bear    1MB Feb 17 20:06 word

How can I get output that is both easy to read and not deceptive large for small files? If ls cannot do it, is there a convenient command-line alternative to ls that can do this?

For example, a desired output could be

-rw-r--r-- 1 bear bear 1.04GB Feb 17 19:47 Stocks.db
-rw-r--r-- 1 bear bear    16B Feb 17 20:06 word
  • Is ls -lh not what you want? – Michael Homer Feb 18 '18 at 1:19
  • O.O - I would downvote my own post if I could. I can't believe I missed that. Thank you – Caleb Feb 18 '18 at 1:28

From ls(1):

   -h, --human-readable
          with -l and/or -s, print human readable sizes (e.g., 1K 234M 2G)

   --si   likewise, but use powers of 1000 not 1024
  • Perfect Answer. – Caleb Feb 18 '18 at 1:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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