Commands by snorf (2)

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


Check These Out

Quick syntax highlighting with multiple output formats
You can specify various output formats, theme styles, etc. $ python -m pygments -o source.png source.py $ python -m pygments -o source.rtf source.py Check available output formats, styles, etc.: $ python -m pygments -L Find pygments module here: http://pygments.org/

Send a backup job to a remote tape drive on another machine over SSH
I use this all the time for taking manual backups of stuff i want to keep but not important enough to backup regularly.

OSX command to take badly formatted xml from the clipboard, cleans it up and puts it back into the clipboard.
This command can be used with xclip or xsel for use on a linux box.

Display last exit status of a command
The variable ? contain the last exit status of a command, it can be printed for troubleshooting purpose.

Recall last argument of previous command
!$ recalls the last argument of the previous command. This is very useful when you have to operate several operations on the same file for example.

Show (only) list of files changed by commit
Lists ONLY the files changed by the given HASH/HEAD/list of hashes, etc. The message, commit ID, author, etc. is not included

Find Duplicate Files (based on size first, then MD5 hash)
This dup finder saves time by comparing size first, then md5sum, it doesn't delete anything, just lists them.

Assign function keys to your frequent commands
This is a common use of bind. Hitting any key after will output the key's character sequence. This makes possible using it into a bind command. So pressing ctrl+v and then F2 will output "^[[12~", once binded every time you'll press the function key F2 it will execute your command. Added the \n to make it execute it as well.

To print a specific line from a file
You can get one specific line during any procedure. Very interesting to be used when you know what line you want.

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"


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: