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:
On Ubuntu, the default editor for visudo is nano. To change the editor to something else (e.g., vi) use this command.
Linux : these script enable you to edit multiple files and remove exact phrase from multiple files
Nicely display permissions in octal format and filename for a given directory
Execute a command on shell logout,and run it until is finished,then shell is closed.
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
Running this code will execute dd in the background, and you'll grab the process ID with '$!' and assign it to the 'pid' variable. Now, you can watch the progress with the following:
while true; do kill -USR1 $pid && sleep 1 && clear; done
The important thing to grasp here isn't the filename or location of your input or output, or even the block size for that matter, but the fact that you can keep an eye on 'dd' as it's running to see where you are at during its execution.
Note that this will not work with files with spaces or characters that need to be escaped. Feel free to leave any comments to improve upon this command, and I'll add it in.
Suppose that you had change in a directory like /home/user/mycode/code, and now you need to list it, instead of type entire path again, use ls !$ to recall path and list. Useful with many commands, this is only an example. (In this case, same result can be achivied with ls .)
Remove blank lines from files, even if some of the lines have whitespace (spaces, tabs, etc.). Also creates a .bak copy of the original file. Works on Mac also.
Thanks to those all those who left comments.
I needed this for wine.
That will open vi with the four README files in different viewports.
Specially handy when you find there is only one file matching your pattern and you don't want to specify the full path.
Add this to .bashrc, then you can quickly create backups from files on current directory, but it only backups files on current directory.
useful when changing config files, coding something or just trying something stupid.
Adds the stdout (standard output) to the beginning of logfile.txt. Change "command" to whatever command you like, such as 'ls' or 'date', etc. It does this by adding the output to a temporary file, then adding the previous contents of logfile.txt to the temp file, then copying the new contents back to the logfile.txt and removing the temp file.
It will return a ranked list of your most commonly-entered commands using your command history
Remove all hidden files in a directory excluding current dir . and parent dir .. with .??* that means files with at least two characters.
If you don't want to commit files to subversion, and don't want those file to show up when doing an "svn stat", this command is what you need