Skip to content

Instantly share code, notes, and snippets.

@angelovangel
Last active February 12, 2020 20:56
Embed
What would you like to do?
SI prefixes with printf

In ksh only (not in bash), this just works:

printf '%#d\n' 105000000
105M

Even this!!!

printf "%#d\n" 12e+12 1.2e+4 12e+6
12T
12k
12M

printf has to be called directly in ksh, but not as part of e.g. awk or as part of a pipe with xargs...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment