Hide

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.

Hide

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:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands by IsraelTorres from sorted by
Terminal - Commands by IsraelTorres - 9 results
echo '<?php echo str_rot13 ("Hello World") ?>' > hw.php && php hw.php && rm hw.php
2011-01-04 21:15:19
User: IsraelTorres
Functions: echo rm
-2

created and tested on:

ProductName: Mac OS X

ProductVersion: 10.6.5

BuildVersion: 10H574

curl -s $dellurl$1 | tr "\"" "\n" | grep "</td></tr><tr><td class=" -m 2 | grep -v "Service Tag" | sed 's/>//g' | sed 's/<\/td<\/tr<tr<td class=//g'
find ~/Music/iTunes/iTunes\ Media/. -name \*.ipa -exec basename {} \; | cut -d \. -f 1 > ~/Desktop/MyAppList`date +%s.txt`
2010-06-16 15:14:32
User: IsraelTorres
Functions: basename cut find
0

omit "> ~/Desktop/MyAppList`date +%s.txt`" if you don't want to print it to a file on your desktop and instead only want to display to console

created and tested on:

ProductName: Mac OS X

ProductVersion: 10.6.3

BuildVersion: 10D573

xxd -l 0x04 $file; xxd -s -0x04 $file
2010-06-05 06:19:02
User: IsraelTorres
1

file carving helps if you know where the file you are looking for starts and ends. It's also an easy way to get data and catalog them for future use with forensic tools like scalpel.

echo "6d5967306474686924697344406b3379" | xxd -r -p
2010-05-24 22:48:41
User: IsraelTorres
Functions: echo
0

Here's a super simple one liner that could have gotten our team 300 points! #facepalm!

echo -n "convert " > itcombino.sh; printf "IMG_%00004u.png " {1..1121} >> itcombino.sh; echo -n "-layers merge _final.png" >> itcombino.sh; chmod +x itcombino.sh && ./itcombino.sh
2010-05-22 03:56:30
User: IsraelTorres
Functions: chmod echo printf
1

This one liner; combines all sequentially numbered files; in this example IMG_0001.png to IMG_1121.png by generating the shell script, making the shell script executable and then running the shell script to combine the 1121 png into a single png file named _final.png

tested on Mac OS X 10.6.3 with ImageMagick 6.5.8-0 2009-11-22 Q16 http://www.imagemagick.org

echo "X-Facebook: from zuckmail ([MTI3LjAuMC4x])" | cut -d \[ -f 2 | cut -d \] -f 1 | openssl base64 -d
2010-05-09 00:46:28
User: IsraelTorres
Functions: cut echo
-2

Currently Facebook has updated their headers to display 127.0.0.1 but if you have saved e-mails from messages and FB related mail you can still reveal the IP. :)

Tested on Mac OS X 10.6.3

echo "$1" | xxd -p | tr '0-9' '5-90-6'; echo "$1" | tr '0-9' '5-90-6' | xxd -r -p
2010-04-27 03:08:47
User: IsraelTorres
Functions: echo tr
2

This is N5 sorta like rot13 but with numbers only.

Encrypt

echo "$1" | xxd -p | tr '0-9' '5-90-6'

Decrypt

echo "$1" | tr '0-9' '5-90-6' | xxd -r -p

currency_convert() { curl -s "http://www.google.com/finance/converter?a=$1&from=$2&to=$3" | sed '/res/!d;s/<[^>]*>//g'; }
2010-03-23 04:13:12
User: IsraelTorres
Functions: sed
1

This works in Mac OS X (10.6.2) (natively comes with curl)

usage: currency_convert $1(amount) $2(from_denomination) $3(to_denomination)