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:
This will extract the differing CSS entries of two files. I've left the initial character (plus or space) in output to show the real differing line, remove the initial character to get a working CSS file. The output CSS file is usable by either adding it in a below the to original.css, or by only using the output but adding @import url("original.css"); in the beginning.
This is very useful for converting Wordpress theme copies into real Wordpress child themes.
Could exclude common lines within entries too, I guess, but that might not be worth the complexity.
Diffs two xml files by formatting them first using xmllint and then invoking diff.
Usage: diffxml XMLFile1 XMLFile2
LC_ALL=C is here to always grep on "differ" whatever your language env.
xargs -n 2 to run gvim -d with 2 arguments
gvim --nofork to use only one instance of gvim
Description is moved to "Sample output" because the html sanitizer for commandlinefu breaks the examples..
Using sed to print newlines as doing it in one line with diff is non-trivial.
Sometimes you need to compare two config files on different servers. Put the file names into the above script and let 'er rip.
The result of this command is a tar with all files that have been modified/added since revision 1792 until HEAD. This command is super useful for incremental releases.
This form is used in patches, svn, git etc. And I've created an alias for it:
alias diff='diff -Naur --strip-trailing-cr'
The latter option is especially useful, when somebody in team works in Windows; could be also used in commands like
svn diff --diff-cmd 'diff --strip-trailing-cr'...
If colordiff utility installed, it is sometimes handy to call this command. Of course, you should create an alias for it. E.g. svndiff.
I often use it to find recently added ou removed device, or using find in /dev, or anything similar.
Just run the command, plug the device, and wait to see him and only him
I had the problem that the Md5 Sum of a file changed after copying it to my external disk.
This unhandy command helped me to fix the problem.
**NOTE** Tekhne's alternative is much more succinct and its output conforms to the files actual contents rather than with white space removed
My command on the other hand uses bash process substitution (and "Minimal" Perl), instead of files, to first remove leading and trailing white space from lines, before diff'ing the streams. Very useful when differences in indentation, such as in programming source code files, may be irrelevant
Checks if a web page has changed. Put it into cron to check periodically.
Change http://www.page.de/test.html and mail@mail.de for your needs.