numfmt: Saving you a trip to Google

Sometimes people accuse me of misnumbering things when I type “4Mhz” or “64Kb,” because there is a difference in numbering and how the abbreviations are used. Which is true.

In my defense, I’ll say that I adopted the uppercase-lowercase style as a concession to the AP Stylebook, which (last time I checked) doesn’t rule on things like mebibytes. I have other reasons, which are rather boring (skip to the end if you want to know).

Regardless, “Mb” seems to cover the idea for me, and I can’t recall ever running into problems, except perhaps when talking about labeling actual, exact, bit-for-bit drive storage space. Which is a scam, anyway.πŸ‘Ώ

But the next time you want to scold your friendly neighborhood Linux blogger, you can critique the writer’s integrity with numfmt. Another of the coreutils gems, you can get almost any proper formatting for a number in as simple a command as this:

kmandla@6m47421: ~$ numfmt --to=iec-i 64738

Or …

kmandla@6m47421: ~$ numfmt --to=iec 64738

Or …

kmandla@6m47421: ~$ numfmt --to=si 64738

And so forth, and so on. numfmt will also convert back from abbreviated formats, in such as this:

kmandla@6m47421: ~$ numfmt --from=si 65K

kmandla@6m47421: ~$ numfmt --from=iec 65K

kmandla@6m47421: ~$ numfmt --from=iec-i 65Ki

A little boring, but useful when I need to convert 59.75Gi back into a full string of numbers. …

kmandla@6m47421: ~$ numfmt --from=iec-i 59.75Gi

Remember this, the next time you need to partition a drive with fdisk. It might just save you a trip to Google.πŸ˜‰

P.S.: For those who really need to know … my rationale on deviating from pure AP Style on MB and MHz and so forth, is that the words are spelled out in full as “megabyte” and “megahertz.” We don’t write “megaByte” or “megaHertz,” or for that matter, split the words as “mega byte” or “mega Hertz.” Since the abbreviations “MB” and “MHz” are deviations from other abbreviations like “km” for kilometer and “kHz” for kilohertz, my mind says “Mb” and “Mhz” aren’t polluting any rules on uppercase and lowercase as they should appear in print. It seems these are determined on a case-by-case basis of what looks right. Of course, you could say that about a lot of things in the AP Stylebook. …

5 thoughts on “numfmt: Saving you a trip to Google

  1. Wordy and Pedantic

    The rationale for using B for byte is to reserve b for bit, as kilobits and megabits and so forth are still commonly used in discussing, for example, communications and network bandwidth.

    As hertz is derived from a proper noun the SI symbol Hz is capitalised, although the spelled-out word isn’t, and while this rule seems as arbitrary as the AP style I’m quite sure there’s a wordy and pedantic justification of it somewhere in the SI’s voluminous documentation! For what are international standardising bodies for, if not the production of wordy and pedantic justifications for arbitrary decisions?

  2. Pingback: sysdig: Information overload | Inconsolation

  3. Pingback: sysdig: Information overload | Linux Admins

Comments are closed.