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:
This assumes your local ip starts with 192.something (e.g. 192.168), it greps ifconfig output for an ip that starts with 192, then strips the extra garbage (besides the ip)
Maybe `ifconfig | grep addr | grep Bcast` would also do it
Here "^M" is NOT "SHIFT+6" and "M". Type CTRL+V+M to get it instead.
Its shortest and easy. And its sed!, which is available by default in all linux flavours.. no need to install extra tools like fromdos.
Will edit *.db files in the same directory with todays date. Useful for doing a mass update to domains on a nameserver, adding spf records, etc.
Looks for a string starting with 200 or 201 followed by 7 numbers, and replaces with todays date. This won't overwrite Ip's but i would still do some double checking after running this.
Make sure your server's date is correct, otherwise insert your own serial number.
should usually follow this command.
get a list of currently running oracle dbs (identified by the pmon process)
show the executable that spawned the process and
show the ORACLE_HOME relative to the environment within which the process is running
tailored to AIX (sed on linux behaves...differently)
suggestions for a better way...please.
This works in Mac OS X (10.6.2) (natively comes with curl)
usage: currency_convert $1(amount) $2(from_denomination) $3(to_denomination)
currency_convert 1 usd inr
This will fetch a metascore from metacritic.com.
It requires a url from metacritic without the http://www.metacritic.com/
Would be cool to use this in some sort of a graph.
You think Expansys in all these countries will sell the HTC Desire for the same price? Well, you'll be surprised. Most of them will be sold at 499.99 EUR but the cheapest can be found in Germany and the most expensive, in Belgium.
specially usefull for sql scripts with insert / update statements, to add a commit command after n statements executed.
This one uses dictionary.com
translate <phrase> <source-language> <output-language>
works from command line
The original was a little bit too complicated for me. This one does not use any variables.
Looks up a word on merriam-webster.com, does a screen scrape for the FIRST audio pronunciation and plays it.
USAGE: Put this one-liner into a shell script (e.g., ~/bin/pronounce) and run it from the command line giving it the word to say:
If the word isn't found in merriam-webster, no audio is played and the script returns an error value. However, M-W is a fairly complete dictionary (better than howjsay.com which won't let you hear how to pronounce naughty words).
ASSUMPTIONS: GNU's sed (which supports -r for extended regular expressions) and Linux's aplay. Aplay can be replaced by any program that can play .WAV files from stdin.
KNOWN BUGS: only the FIRST pronunciation is played, which is problematic if you wanted a particular form (plural, adjectival, etc) of the word. For example, if you run this:
you'll hear a voice saying "onomatopoeia".
Playing the correct form of the word is possible, but doing so might make the screen scraper even more fragile than it already is. (The slightest change to the format of m-w.com could break it).
translate <phrase> <source-language> <output-language>
translate hello en es
See this for a list of language codes:
Determines the flavor of a shared library by looking at the addresses of its exposed functions and seeing if they are 16 bytes or 8 bytes long. The command is written so the library you are querying is passed to a variable up font -- it would be simple to convert this to a bash function or script using this format.
This function is used to sort selected lines of a text file to the end of that file. Especially useful in cases where human intervention is necessary to sort out parts of a file. Let's say that you have a text file which contains the words
For whatever reason, you want to sort all words rhyming with 'tough' to the bottom of the file, and all words denoting colors to the top, while keeping the order of the rest of the file intact.
'$EDITOR' will open, showing all of the lines in the given file, numbered with '0' padding. Adding a '~' to the beginning of the line will cause the line to sort to the end of the file, adding '!' will cause it to sort to the beginning.
Easy way to grab the IP address of a machine for easy script use. If needed a "| grep -v 127.0.0.1" at the end will suppress localhost.