Weather on the Command line
$ curl -s "http://www.google.com/ig/api?weather=New%20York" | sed 's|.*<temp_f data="\([^"]*\)"/>.*|\1|' Will return temperature in Fahrenheit of a location (New York City in example). Uses a...
View ArticleGet Google Reader unread count
$ curl -s -H "Authorization: GoogleLogin auth=$auth" "http://www.google.com/reader/api/0/unread-count?output=json" | tr '{' '\n' | sed 's/.*"count":\([0-9]*\),".*/\1/' | grep -E ^[0-9]+$ | tr '\n' '+'...
View ArticleUrl Encode
$ echo "$@" | sed 's/ /%20/g;s/!/%21/g;s/"/%22/g;s/#/%23/g;s/\$/%24/g;s/\&/%26/g;s/'\''/%27/g;s/(/%28/g;s/)/%29/g;s/:/%3A/g' View this command to comment, vote or add to favourites View all...
View ArticleGeo Weather
$ curl -s http://www.google.com/ig/api?weather=$(curl -s "http://api.hostip.info/get_html.php?ip=$(curl -s icanhazip.com)" | grep City | sed 's/City: \(.*\)/\1/' | sed 's/ /%20/g' | sed "s/'/%27/g") |...
View ArticleGet your commandlinefu points (upvotes - downvotes)
$ username=matthewbauer; curl -s http://www.commandlinefu.com/commands/by/$username/json | tr '{' '\n' | grep -Eo ',"votes":"[0-9\-]+","' | grep -Eo '[0-9\-]+' | tr '\n' '+' | sed 's/+$/\n/' | bc This...
View ArticleAutomagically create a /etc/hosts file based on your DHCP list (only works on...
$ curl -s -u $username:$password http://192.168.1.1/DHCPTable.htm | grep '<td>.* </td>' | sed 's|\t<td>\(.*\) </td>\r|\1|' | tr '\n' ';' | sed...
View ArticleGoogle Spell Checker
$ spellcheck(){ curl -sd "<spellrequest><text>$1</text></spellrequest>" https://www.google.com/tbproxy/spell | sed 's/.*<spellresult...
View ArticleMouse Tracking
$ while true; do xdotool getmouselocation | sed 's/x:\(.*\) y:\(.*\) screen:.*/\1, \2/' >> ./mouse-tracking; sleep 10; done Will track your mouse and save it to a file. You can use gnuplot to...
View ArticleSave xkcd to a pdf with captions
$ curl -sL xkcd.com | grep '<img [^>]*/><br/>' | sed -r 's|<img src="(.*)" title="(.*)" alt="(.*)" /><br/>|\1\t\2\t\3|' > /tmp/a; curl -s $(cat /tmp/a | cut -f1) | convert...
View ArticleYour name backwards
$ espeak "$USER" --stdout | sox - -t mp3 - reverse | mpg123 - View this command to comment, vote or add to favourites View all commands by matthewbauer Diff your entire server config at ScriptRock.com
View ArticleGoogle Translate
$ 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/'; } Usage: translate...
View ArticleDetect Language of a string
$ detectlanguage(){ curl -s "http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&q=$@" | sed 's/{"responseData": {"language":"\([^"]*\)".*/\1\n/'; } Usage: detectlanguage <phrase>...
View ArticlePronounce an English word using Merriam-Webster.com
$ pronounce(){ wget -qO- $(wget -qO- "http://www.m-w.com/dictionary/$@" | grep 'return au' | sed -r "s|.*return au\('([^']*)', '([^'])[^']*'\).*|http://cougar.eb.com/soundc11/\2/\1|") | aplay -q; } The...
View ArticlePronounce an English word using Dictionary.com
$ pronounce(){ wget -qO- $(wget -qO- "http://dictionary.reference.com/browse/$@" | grep 'soundUrl' | head -n 1 | sed 's|.*soundUrl=\([^&]*\)&.*|\1|' | sed 's/%3A/:/g;s/%2F/\//g') | mpg123 -; }...
View Articlex bottles of beer on the wall graph
$ (echo "plot '-' with lines"; for x in $(seq 1 100); do curl -s "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=$(echo $x bottles of beer on the wall|sed 's/ /%20/g')"|sed...
View ArticleExport OPML from Google Reader
$ export-opml(){ curl -sH "Authorization: GoogleLogin auth=$(curl -sd "Email=$1&Passwd=$2&service=reader" https://www.google.com/accounts/ClientLogin | grep Auth | sed 's/Auth=\(.*\)/\1/')"...
View ArticleGet a metascore from metacritic.com
$ metascore(){ curl -s "http://www.metacritic.com/$@" | sed -rn 's|\t*<!-- metascore --><div id="metascore" class=".*">([^<]*)</div>|\1|p'; } This will fetch a metascore from...
View ArticleAdd to Instapaper
$ instapaper-add(){ curl -s -d username="$1" -d password="$2" -d url="$3" https://www.instapaper.com/api/add; } Adds URL to Instapaper. Usage: instapaper-add user@example.com 12345...
View ArticleList a phone's filesystem with bitpim
$ bitpim -p $PHONE_PORT ls This will list your phone's filesystem with bitpim. (works on many LG, Samsung, and Sanyo) See http://www.bitpim.org/help/phones-featuressupported.htm for full list. View...
View ArticleChange the homepage of Chromium
$ change-homepage(){ sed -ri 's|( "homepage": ").*(",)|\1'"$@"'\2|' .config/chromium/Default/Preferences; } View this command to comment, vote or add to favourites View all commands by matthewbauer...
View Article