Robert Elder Software Inc.
  • Home
  • Store
  • Blog
  • Contact
  • Home
  • Store
  • Blog
  • Contact
  • #linux
  • |
  • #commandline
  • |
  • #softwareengineering
  • |
  • #embeddedsystems
  • |
  • #compilers
  • ...
  • View All >>

Intro To 'numfmt' Command In Linux

2024-06-01 - By Robert Elder

     I use the 'numfmt' command to format numbers that quantify data storage:

echo '1024' | numfmt
1024
echo '1024' | numfmt --to=si
1.1K
echo '1024' | numfmt --to=iec
1.0K
echo '1024' | numfmt --to=iec-i
1.0Ki

A Real-World Use Case

     Recently, my YouTube shorts videos haven't been doing well:

Lower Views

     Kids these days just aren't interested in the same old boring output from the 'ls' command:

ls -l
total 108
-rw-rw-r-- 1 robert robert 54957 May 27 22:58 cat.png
-rw-rw-r-- 1 robert robert 44824 May 27 22:58 main.c
-rw-rw-r-- 1 robert robert  4324 May 27 22:58 README.txt

     But I can use the 'numfmt' command to format the output of my commands in such a way that appeals to terminally online people who are obsessed with memes and anime culture:

ls -l | numfmt --field=5 --format="πŸ’—UΟ‰UπŸ’— %4f πŸ₯ΊπŸ‘‰πŸ‘ˆ"
total 108
-rw-rw-r-- 1 robert robert πŸ’—UΟ‰UπŸ’— 54957 πŸ₯ΊπŸ‘‰πŸ‘ˆ May 27 22:58 cat.png
-rw-rw-r-- 1 robert robert πŸ’—UΟ‰UπŸ’— 44824 πŸ₯ΊπŸ‘‰πŸ‘ˆ May 27 22:58 main.c
-rw-rw-r-- 1 robert robert πŸ’—UΟ‰UπŸ’— 4324 πŸ₯ΊπŸ‘‰πŸ‘ˆ May 27 22:58 README.txt
Anime Memes

     The '--format' flag allows me to specify how the size quantity is represented, and the '--field' flag specifies which columns are to be formatted.

Format Sizes In SI or IEC Representation

     I can also use the '--to' flag to represent the file size in SI, IEC or two letter IEC representation:

numfmt --from=si --to=iec 1M
977K
numfmt --from=si --to=iec 1048576
1.0M

Format Arbitrary Size Quantities

     The 'numfmt' command can also accept optional numbers as input as well:

numfmt --from=si --to=iec 1Z
868E
numfmt --from=si --to=iec 1E
889P
numfmt --from=si --to=iec 1P
910T
numfmt --from=si --to=iec 1T
932G
numfmt --from=si --to=iec 1G
954M
numfmt --from=si --to=iec 1M
977K
numfmt --from=si --to=iec 1K
1000

     This can be useful for performing inline unit conversions.

     Now, all the people with anime profile pictures will press the like button on my videos, and I'll become YouTube famous:

Anime Profile Picture

     And that's why the 'numfmt' command is my favourite Linux command.

Intro To 'stty' Command In Linux
Intro To 'stty' Command In Linux
Published 2023-10-04
Terminal Block Mining Simulation Game
$1.00 CAD
Terminal Block Mining Simulation Game
Intro To 'nproc' Command In Linux
Intro To 'nproc' Command In Linux
Published 2023-07-15
Intro To 'comm' Command In Linux
Intro To 'comm' Command In Linux
Published 2023-09-06
How To Force The 'true' Command To Return 'false'
How To Force The 'true' Command To Return 'false'
Published 2023-07-09
A Surprisingly Common Mistake Involving Wildcards & The Find Command
A Surprisingly Common Mistake Involving Wildcards & The Find Command
Published 2020-01-21
A Guide to Recording 660FPS Video On A $6 Raspberry Pi Camera
A Guide to Recording 660FPS Video On A $6 Raspberry Pi Camera
Published 2019-08-01
Intro To 'chroot' Command In Linux
Intro To 'chroot' Command In Linux
Published 2023-06-23
Join My Mailing List
Privacy Policy
Why Bother Subscribing?
  • Free Software/Engineering Content. I publish all of my educational content publicly for free so everybody can make use of it.  Why bother signing up for a paid 'course', when you can just sign up for this email list?
  • Read about cool new products that I'm building. How do I make money? Glad you asked!  You'll get some emails with examples of things that I sell.  You might even get some business ideas of your own :)
  • People actually like this email list. I know that sounds crazy, because who actually subscribes to email lists these days, right?  Well, some do, and if you end up not liking it, I give you permission to unsubscribe and mark it as spam.
© 2025 Robert Elder Software Inc.
SocialSocialSocialSocialSocialSocialSocial
Privacy Policy      Store Policies      Terms of Use