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/
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.
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.
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:
terms inclosing '()' must be enclosed by "" (soft quotes)
bash variables must be referenced: b $x/$y
ugly bracket checking (balanced, fractions...)
default precision 2
You're behind on your TV catch-up, but how far behind? This command tries to open mplayer against all files in the current dir. If it's a video file it will contain ID_LENGTH, which is summed and output in hours, minutes and seconds.
Someone better at awk could probably reduce this down a lot.
One pipe less.
-l auto-selects many more digits (but you can round/truncate in your head, right) plus it loads a few math functions like sin().
Infinitely plays beeps with sinusoidally changing sound frequency. Ideal for alarm on an event.
defines a handy function for quick calculations from cli.
Might be more useful if you were able to print it in Days HH:MM:SS format as:
perl -e [email protected]=gmtime(234234);printf("%d Days %02d:%02d:%02ds\n",@p[7,2,1,0]);'
But I'm not exactly sure how to replace the 234234 with the output of the countdown time. (Having some problems with nested quoting/command substitution). Help would be appreciated :)
Easily convert numbers to their representations in different bases. Passing
"ibase=16; obase=8; F2A"
to bc will convert F2A (3882 in decimal) from Hex to Octal, and so on.
Useful for quick calculations at the command line. $math_expr is any arithmetic expression (see sample output):
More options in the bc man page.
bc is a wonderful calculator. Just type bc at the command line and have at it. Ctrl+D (or type quit) will get you out. This usage is just scratching the surface: bc can handle a mini scripting language, complete with variable, statements, loop, conditional statements and more. Do a man page on it to find out.
command to turn off your computer when you go home and can not wait
queries local memcached for stats, calculates hit/get ratio and prints it out.
This is a quick and dirty way to generate a (non-floating-point) CPU-bound task to benchmark. Adjust "20" to higher or lower values, as needed. As a benchmark this is probably a little less bogus than bogomips, and it will run anywhere 'bc' does.