Is there a standard command that will format a simple value (size in bytes) as a human readable format (similar to the -h
switch on du
, ls
, ...)?
eg.
echo 1852 | format # should print 1.9K
echo 3145728000 | format # should print 3.0G
Is there a standard command that will format a simple value (size in bytes) as a human readable format (similar to the -h
switch on du
, ls
, ...)?
eg.
echo 1852 | format # should print 1.9K
echo 3145728000 | format # should print 3.0G
I think you are looking for the numfmt
tool, which can covert raw strings to known math standards, e.g.
echo 3145728000 | numfmt --to=iec
3.0G
The tool is part of the GNU coreutils family.