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





Commands tagged translate from sorted by
Terminal - Commands tagged translate - 10 results
translate () {lang="ru"; text=`echo $* | sed 's/ /%20/g'`; curl -s -A "Mozilla/5.0" "http://translate.google.com/translate_a/t?client=t&text=$text&sl=auto&tl=$lang" | sed 's/\[\[\[\"//' | cut -d \" -f 1}
2014-07-10 18:26:34
User: 2b
Functions: cut sed

Change lang from ru to something else.

Curl version - Mac OS etc, any system w/o wget.

translate(){wget -U "Mozilla/5.0" -qO - "https://translate.google.com/translate_a/single?client=t&sl=${3:-auto}&tl=${2:-en}&dt=t&q=$1" | cut -d'"' -f2}
2014-06-10 12:08:51
User: klisanor
Functions: cut
translate <some phrase> [output-language] [source-language]

1) "some phrase" should be in quotes

2) [output-language] - optional (default: English)

3) [source-language] - optional (default: auto)

translate "bonjour petit lapin"

hello little rabbit

translate "bonjour petit lapin" en

hello little rabbit

translate "bonjour petit lapin" en fr

hello little rabbit

leo (){ l="en"; if [ "${1:0:1}" = "-" ]; then l=${1:1:2};shift;fi;Q="$*";curl -s "https://dict.leo.org/${l}de/?search=${Q// /%20}" | html2text | sed -e '0,/H.ufigste .*/d;/Weitere Aktionen/,$d;/f.r Sie .*:/,$d' | grep -aEA900 '^\*{5} .*$'; }
2013-06-24 22:35:46
User: michelsberg
Functions: grep sed

Translate strings from non-german to german (and vice versa) using LEO. Put it in your ~/.bashrc.


leo words

To use another language other than english, use an option:

leo -xx words

Valid language options:

ch - chinese

en - english

es - spanish

fr - french

it - italian

pl - polish

pt - portuguese

ru - russian

The other language will always be german!

tr a-z A-Z < file.txt
function say { mplayer -really-quiet "http://translate.google.com/translate_tts?tl=en&q=$1"; }
2011-12-16 20:56:40
User: tikal808

Put the string above in your ~/.bashrc or ~/.bash_profile, then source the file. Make sure your sound output is working, you have mplayer installed, then type in a word or sentence similar to below:

say "why won't anyone talk to me?"

It's easy to get the language to be different by changing the "en" in the string to be "de" or some other language that Google Translate supports. Have multiple "say" functions, like "say-en" "say-de", etc.

wget -U "Mozilla/5.0" -qO - "http://translate.google.com/translate_a/t?client=t&text=translation+example&sl=auto&tl=fr" | sed 's/\[\[\[\"//' | cut -d \" -f 1
2011-03-06 13:46:16
User: sairon
Functions: cut sed wget

substitute "example" with desired string;

tl = target language (en, fr, de, hu, ...);

you can leave sl parameter as-is (autodetection works fine)

tw translate.google.com.de-en `xsel`
2010-06-11 22:28:28
User: dbbolton

Translate the X selection from German to English. The tw program is available from Savannah: http://mirror.its.uidaho.edu/pub/savannah/twandgtw/

I'm posting this because the base Debian system also does not include curl.

translate() { lng1="$1";lng2="$2";shift;shift; wget -qO- "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=${@// /+}&langpair=$lng1|$lng2" | sed 's/.*"translatedText":"\([^"]*\)".*}/\1\n/'; }
cmd=$( wget -qO- "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=$1&langpair=$2|${3:-en}" | sed 's/.*"translatedText":"\([^"]*\)".*}/\1\n/'; ); echo "$cmd"
2010-03-13 01:09:00
User: dtolj
Functions: sed wget
translate <phrase> <source-language> <output-language>

works from command line

translate(){ wget -qO- "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=$1&langpair=$2|${3:-en}" | sed 's/.*"translatedText":"\([^"]*\)".*}/\1\n/'; }
2010-03-08 03:15:48
User: matthewbauer
Functions: sed wget


translate <phrase> <source-language> <output-language>


translate hello en es

See this for a list of language codes: