Search commandlinefu from the command line

(curl -d q=grep http://www.commandlinefu.com/search/autocomplete) | egrep 'autocomplete|votes|destination' | perl -pi -e 's/a style="display:none" class="destination" href="//g;s/<[^>]*>//g;s/">$/\n\n/g;s/^ +//g;s/^\//http:\/\/commandlinefu.com\//g'
There's probably a more efficient way to do this rather than the relatively long perl program, but perl is my hammer, so text processing looks like a nail. This is of course a lot to type all at once. You can make it better by putting this somewhere: clf () { (curl -d "q=$@" http://www.commandlinefu.com/search/autocomplete 2>/dev/null) | egrep 'autocomplete|votes|destination' | perl -pi -e 's/<a style="display:none" class="destination" href="//g;s/<[^>]*>//g;s/">$/\n\n/g;s/^ +|\([0-9]+ votes,//g;s/^\//http:\/\/commandlinefu.com\//g'; } Then, to look up any command, you can do this: clf diff This is similar to http://www.colivre.coop.br/Aurium/CLFUSearch except that it's just one line, so more in the spirit of CLF, in my opinion.
Sample Output
grep --color=auto -iRnH "$search_word" $directory

Grep for word in directory (recursive)                 
http://commandlinefu.com/commands/view/1144/grep-for-word-in-directory-recursive


grep -i --color=auto

Grep colorized                 
http://commandlinefu.com/commands/view/2004/grep-colorized

1
By: isaacs
2009-07-08 22:10:49

These Might Interest You

What Others Think

#!/bin/sh protocol="http" primeurl="commandlinefu.com" fulltext="fulltext=Search&" google=" domains="domains="$lng$primeurl"&" sitesearch="sitesearch="$lng$primeurl"&" btnI="btnI=I%27m+Feeling+Lucky&" gl="gl=us&" q="q="$@ baseurl=$google$domains$sitesearch$fulltext$gl$btnI$q if [ "$1" == "-g" ] then google=" domains="domains="$lng$primeurl"&" sitesearch="sitesearch="$lng$primeurl"&" btnI="btnI=I%27m+Feeling+Lucky&" gl="ql=us&" shift q="q="$@ baseurl=$google$domains$sitesearch$fulltext$gl$q fi url=$protocol://$baseurl open "$url" # `open' is MacOSX specific command ---------------
commandlinefu · 466 weeks and 6 days ago
curl -sd q=grep http://www.commandlinefu.com/search/autocomplete |html2text
commandlinefu · 466 weeks and 6 days ago
No html tags I guess! http://www.mbayer.de/html2text/
commandlinefu · 466 weeks and 6 days ago
No html tags I guess! http://www.mbayer.de/html2text/
commandlinefu · 466 weeks and 6 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands



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: