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.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
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:
grep '^[^#]' sample.conf
\__/ |||| \_________/
| |||| |
| |||| \- Filename
| ||||
| |||\- Only character in group is '#'
| |||
| ||\- Negate character group (will match any cahracter *not* in the
| || group)
| ||
| |\- Start new character group (will match any character in the
| | group)
| |
| \- Match beginning of line
|
\- Run grep
Empty lines will also be not matched, because there has to be at least one non-hash-sign character in the line.
Simplicity tends to win out on commandlinefu.com Also, why type multiple filenames when range operators work too. Saves finger abuse and time and reduces the chances for mistakes.
Tail is much faster than sed, awk because it doesn't check for regular expressions.
WARNING! This command may set an invalid permission under your current directory.
This command will set the 0755 permissions to all directories under your current directory. An alternative version of this command is: find ~/.ssh -type d -exec chmod 0700 {} \;
Ever need to output an entire directory and subdirectory contents to a file? This is a simple one liner but it does the trick every time. Omit -la and use only -R for just the names
If you edit your .profile you need to refresh it for changes to take place. Simple way to refresh is logout and login. This command is the quickest way to do it.
If you're deleting some variables, they would not get nulled with this command but just removed.
This will create a new directory called MyProject with a pom.xml and the following tree structure:
MyProject
|-->pom.xml
|-->src
| |-->main
| | |-->java
| | | |-->my
| | | | |-->work
| | | | | |-->App.java
| |-->test
| | |-->java
| | | |-->my
| | | | |-->work
| | | | | |-->AppTest.java
Will rot 13 whatever parameter follows 'rot13', whether it is a string or a file. Additionally, it will rot 5 each digit in a number
Use optimized sed to big file/stream to reduce execution time
Use
sed '/foo/ s/foo/foobar/g' <filename>
insted of sed
's/foo/foobar/g' <filename>
if you want to replace "foo" with "bar" in all files in a folder, and put the resulting files into a new subfolder
Finds a string in files recursively below the current directory on systems without the "egrep" and its "-r" functionality.