alternative using 'host' Show Sample Output
Do this with caution.
Reverse DNS lookups, from a file with list of IP's, here the file is called lookups.txt
search argument in PATH accept grep expressions without args, list all binaries found in PATH Show Sample Output
Uses curl to download page of membership of US Congress. Use sed to strip HTML then perl to print a line starting with two tabs (a line with a representative) Show Sample Output
From Hong Kong Observatory wap site ;) Show Sample Output
"get Hong Kong weather infomation from HK Observatory From Hong Kong Observatory wap site ;)" other one showed alot of blank lines for me Show Sample Output
You'll run into trouble if you have files w/ missing newlines at the end. I tried to use
PAGER='sed \$q' git blame
and even
PAGER='sed \$q' git -p blame
to force a newline at the end, but as soon as the output is redirected, git seems to ignore the pager.
Useful when you need to write e.g. an INSERT for a table with a large number of columns. This command will retrieve the column names and comma-separate them ready for INSERT INTO(...), removing the last comma.
This command uses the top voted "Get your external IP" command from commandlinefu.com to get your external IP address. Use this and you will always be using the communities favourite command. This is a tongue-in-cheek entry and not recommended for actual usage.
same thing as the other
There's too many options to number, My curiosity has forced me to make it using only sed. Maybe useful... or not... :-S
Print out contents of file with line numbers. This version will print a number for every line, and separates the numbering from the line with a tab. Show Sample Output
I needed to add a line to my crontab from within a script and didn't want to have to write my own temporary file.
You may find you need to reload the crond after this to make the change take effect.
e.g.:
if [ -x /sbin/service ]
then
/sbin/service crond reload
else
CRON_PID=`ps -furoot | awk '/[^a-z]cron(d)?$/{print $2}'`
if [ -n "$CRON_PID" ]
then
kill -HUP $CRON_PID
fi
fi
The reason I had CRON_HOUR and CRON_MINS instead of numbers is that I wanted to generate a random time between midnight & 6AM to run the job, which I did with:
CRON_HOUR=`/usr/bin/perl -e 'printf "%02d\n", int(rand(6))'`
CRON_MINS=`/usr/bin/perl -e 'printf "%02d\n", int(rand(60));'`
Combines a few repetitive tasks when compiling source code. Especially useful when a hypen in a file-name breaks tab completion. 1.) wget source.tar.gz 2.) tar xzvf source.tar.gz 3.) cd source 4.) ls From there you can run ./configure, make and etc. Show Sample Output
xargs deals badly with special characters (such as space, ' and "). To see the problem try this: touch important_file touch 'not important_file' ls not* | xargs rm Parallel https://savannah.nongnu.org/projects/parallel/ does not have this problem.
Will return temperature in Fahrenheit of a location (New York City in example). Uses a Google API. Show Sample Output
Get Google Reader unread count from the command line.
You'll have to define your auth token with $auth
Or use:
curl -s -H "Authorization: GoogleLogin auth=$(curl -sd "Email=$email&Passwd=$password&service=reader" https://www.google.com/accounts/ClientLogin | grep Auth | sed 's/Auth=\(.*\)/\1/')" "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' '+' | sed 's/\(.*\)+/\1\n/' | bc
Show Sample Output
You WILL have problems if the files have the same name.
Use cases: consolidate music library and unify photos (especially if your camera separates images by dates).
After running the command and verifying if there was no name issues, you can use
ls -d */ | sed -e 's/^/\"/g' -e 's/$/\"/g' | xargs rm -r
to remove now empty subdirectories.
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.
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
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: