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/
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.
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.
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:
Info has some of the worst keybindings I've ever seen. Being a vim user, I attribute that to emacs influence. Use the --vi-keys option to use some of the vi keybindings, although this won't change all the keybindings. Use the "infokey" program to have more control over info keybindings.
Very handy to bring the word currently under the cursor into a :s command in Vim.
If the cursor was on the word "eggs":
:s/ ==> :s/eggs
the middle command between the ; and ; is the vi commands that insert that line into the last line of the file, the esc with the carets is literally hitting the escape key, you have to have the smbfs package installed to do it, I use it to access my iTunes music on my mac from my linux PC's with amarok so I can play the music anywhere in the house. among other things, it allows you to access the files on that share from your computer anytime you're on that network.
Within vi allow to empty a text file in one shot
The -R flag prevents you from making changes to a file, useful when you only want to view the file. This command is nicer than the 'more' or 'less' commands because for source codes, vi shows syntax highlight.
This command delete all the empty lines (include the lines with space) from a file.
g = global command
\S = non-whitespace character; !\S the opposite
d = delete a range
On command mode in Vim you can save parts of the current buffer in another file.
* The 'n' value represents the first line of the new file.
* The 'm' value represents the last line of the new file.
* newfile.txt is the newfile.
The results are similar to this command in perl:
perl -ne 'print if n..m' in.sql > out.sql
Replace all ocurrences in the file.
The g option is to replace more than one occurrence in the same line. Whitout the g option, it only replace the first occurrence in the line.
Edit the files, each in a separate tab. use gT and gt to move to the left- and right-tab, respectively. to add another tab while editing, type ':tabe filename'
Creates a full snapshot of your current vim session, including tabs, open buffers, cursor positions, everything. Can be resumed with vim -S . Useful for those times when you HAVE to close vim, but you don't want to lose all your hard-opened buffers and windows. The ! will cause vim to overwrite the file if it already exists. It is not necessary, but useful if you frequently save to the same file (like session.vim or something).
You can then switch from a file to another with ^W^W
This will append the output of "command" to whatever file you're currently editing in vim. Who else has good vim tricks? :)
The hyphen tells vim to open from STDOUT - saves having to create temporary files.