Quantcast
Channel: A standard tool to convert a byte-count into human KiB MiB etc; like du, ls1 - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 21

Answer by craeckie for A standard tool to convert a byte-count into human KiB MiB etc; like du, ls1

$
0
0

@don_crissti's first Answer is good, but can be even shorter using Here Strings, e.g.

$ numfmt --to=iec-i <<< "12345"
13Ki

$ numfmt --to=iec-i --suffix=B <<< "1234567"
1.2MiB

or even

$ numfmt --from=iec-i --to=iec-i --suffix=B <<< "12345Ki"
13MiB

if <<< is not available you can use e.g.

$ echo "1234567" | numfmt --to=iec-i --suffix=B
1.2MiB

Viewing all articles
Browse latest Browse all 21

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>