0

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
2
  • Is ls -lh not what you want? Commented Feb 18, 2018 at 1:19
  • O.O - I would downvote my own post if I could. I can't believe I missed that. Thank you
    – Caleb
    Commented Feb 18, 2018 at 1:28

1 Answer 1

0

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
1
  • Perfect Answer.
    – Caleb
    Commented Feb 18, 2018 at 1:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .