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:
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.
Here's a version that doesn't use find.
Removes trailing newline; colon becomes record separator and newline becomes field separator, only the first field is ever printed. Replaces empty entries with $PWD. Also prepend relative directories (like ".") with the current directory ($PWD). Can change PWD with env(1) to get tricky in (non-Bourne) scripts.
KDE4 is great, but still a bit buggy, and sometimes plasma requires to be restarted. Instead of quitting it with "killall plasma", which might loose your preferences (widgets, etc.), kquitapp will cleanly quit it. Tip: you can type this in the "Alt+F2" window, and then type "plasma" in Alt+F2 again to restart plasma (be patient though...).
The sample command searches for PHP files replacing tabs with spaces.
-u NONE # don't use vimrc
one may pass
Look at this http://susepaste.org/69028693 also
Here's the other way of doing it in vim: setting a recursive macro. 'gg' brings you to the top of the buffer, 'qqq' clears the 'q' macro, 'qq' starts recording a macro called 'q', '/^$' moves the cursor to the next empty line, 'dd' deletes the line that the cursor is on, '@q' calls the 'q' macro (currently empty because of 'qqq'), and 'q' stops recording the macro. '@q' calls the macro.
It will run until it cannot find another blank line, at which point it will throw up an error and cease.
While this is longer than the regex, you can use it without having to move your thoughts from 'vim-mode' to 'regex-mode'.
You can use this command to delete CVS/svn folders on given project.
# git commit -m"Jira #404 - `whatthecommit`"
Will move in that case every file in the current folder older than 30 days to the "old" folder
Replace "mv $i old/" by any command such as rm / echo to do something different.
If you have a directory with many working copies of various subversion projects and you want to update them all at once, this one may be for you.
This awk command prints a histogram of the number of times 'emergency' is the first word in a line, per day, in an irssi (IRC client) log file.
You should install qpdf.
That way, you can have a copy without any password required.
cn stands for "Cat Null"
The idea is that sometimes you run across something on maybe a webpage - like commandlinefu - that you want to try out on your terminal. You could put a '#' in and then paste it, but what if it is several lines?
This command will echo the pasted characters to the screen and divert them to the bit bucket.
Put this simple alias in your .bashrc, hit cn, paste away, and hit a ctrl+c or a ctrl+d when you are done to get your prompt back.
Finds the line number matching the regex, then passes that to BC for some math, passes that to head, and uses tail to trim off the unwanted section at the top. The whole thing is spit out to a script that can then be shared or run. Comes in handy for reading select sections from error logs.
Randomize GNU grep's colors 31-36 excluding black and white.