Page MenuHomeFreeBSD

Tell the world how to convert gigabytes to bytes with units(1) easily
ClosedPublic

Authored by 0mp on Mar 17 2020, 9:37 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Sep 3, 7:06 PM
Unknown Object (File)
Thu, Sep 3, 9:30 AM
Unknown Object (File)
Fri, Aug 28, 4:57 PM
Unknown Object (File)
Fri, Aug 28, 2:27 PM
Unknown Object (File)
Thu, Aug 27, 6:52 PM
Unknown Object (File)
Thu, Aug 27, 6:45 PM
Unknown Object (File)
Thu, Aug 27, 6:44 PM
Unknown Object (File)
Thu, Aug 27, 5:41 PM
Subscribers

Details

Summary
Tell the world how to convert gigabytes to bytes with units(1) easily

It turns out that units(1) is not as horrible to use in scripts as I initially
thought. When the --terse flag is combined with an appropriate output format
(set via --output-format), units(1) is actually capable of producing very nice
results. For example:

    units -o %0.f -t '4 gigabytes' bytes

is just going to print out the expected value of 4294967296.

There is no time to waste. People have to know about it.

I am adding an example for this at the top of the examples section because
this is what users are most likely looking for.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 29975
Build 27788: arc lint + arc unit

Event Timeline

Who am I to stand in the way of a good unit conversion example? ;)
Go ahead with the commit! Thanks.

This revision is now accepted and ready to land.Mar 17 2020, 9:55 AM
In D24096#529772, @bcr wrote:

Who am I to stand in the way of a good unit conversion example? ;)
Go ahead with the commit! Thanks.

Awesome!