What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Universal configuration monitoring and system of record for IT.

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags





Convert numbers to SI notation

Terminal - Convert numbers to SI notation
$ awk '{ split(sprintf("%1.3e", $1), b, "e"); p = substr("yzafpnum_kMGTPEZY", (b[2]/3)+9, 1); o = sprintf("%f", b[1] * (10 ^ (b[2]%3))); gsub(/\./, p, o); print substr( gensub(/_[[:digit:]]*/, "", "g", o), 1, 4); }' < test.dat
2009-07-22 16:54:14
User: mungewell
Functions: awk
Convert numbers to SI notation

converts any number on the 'stdin' to SI notation. My version limits to 3 digits of precious (working with 10% resistors).


There are 3 alternatives - vote for the best!

Terminal - Alternatives

Know a better way?

If you can do better, submit your command here.

What others think


Comment by RickDeckardt 331 weeks and 1 day ago

More readable version (with biasing for m,u,n,..)



split(sprintf("%1.3e", $1), bits, "e");

if (bits[2] < 0) {

bits[1] *= 1000;

bits[2] -= 3;


prefix = substr("yzafpnum_kMGTPEZY", (bits[2]/3)+9, 1)

output = sprintf("%f", bits[1] * (10 ^ (bits[2]%3)));

gsub(/\./, prefix, output);

print substr( gensub(/_[[:digit:]]*/, "", "g", output), 1, 4);



Comment by mungewell 331 weeks and 1 day ago

yeah yeah cygwin you know... ;-)

Comment by mungewell 331 weeks and 1 day ago

There has GOT to be a better way to do this

Comment by linuxrawkstar 331 weeks and 1 day ago

I wish I could find a better way, spent about an hour googling.

Better version:



split(sprintf("%-1.2e", $1), bits, "e");

prefix = substr("yzafpnum.kMGTPEZY", (bits[2]/3)+9, 1)

output = sprintf("%f", bits[1] * (10 ^ ((bits[2]+18)%3)));

gsub(/\./, prefix, output);

print gensub(/\.$/, "", "g", gensub(/[0]*$/, "", "g", output));



Comment by mungewell 331 weeks and 1 day ago

Your point of view

You must be signed in to comment.