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:
Assumed dir A, B, C are subdirs of the current dir
Exact syntax of the command is:
rsync -v -r --size-only --compare-dest=/path_to_A/A/ /path_to_B/B/ /path_to_C/C/
(do not omit end-slashes, since that would copy only the names and not the contents of subdirs of dir B to dir C)
You can replace --size-only with --checksum for more thorough file differences validation
-n, --dry-run perform a trial run with no changes made
Compares the md5 checksums of the contents of two directories, outputting the checksum and filename where any files differ. Shows only the file name, not the full path.
Compute the md5 checksums for the contents of two mirrored directories, then sort and diff the results. If everything matches, nothing is returned. Otherwise, any checksums which do not match, or which exist in one tree but not the other, are returned. As you might imagine, the output is useful only if no errors are found, because only the checksums, not filenames, are returned. I hope to address this, or that someone else will!
Runs a diff on two files ignore comments and blank lines (diff -I=RE does not work as expected). Adapted from a post found on stackexchange.
Execute a process or list of commands in the given interval and output the difference in output.
Is this not the same
Use vim's diff mode to edit two or more files in one window. The '+diffoff!' turns off diff highlighting when the session is started.
Use ctrl+w + ctrl+w to switch between windows.
Outputs the number of different pixels.
2 params to increase tolerance:
* thumbnails size
* fuzz, the color distance tolerance
See http://en.positon.org/post/Compare-/-diff-between-two-images for more details.
Compare the ls -Rl output of two directories in meld (you can also use diff -y instead of meld).
The normal output of 'diff' is a wonderful thing. But just sometimes, you want something that is a little more... well... readable.
This is that command.
-d - (optional) find the minimal set of changes
-b - (optional) ignore changes in the amount of whitespace
-B - (optional) ignore changes that just insert or delete blank lines
-y - this is where the magic happens! Use the side-by-side output format.
-w $COLUMNS - more magic! Instead of using 80 columns, use the current width of the terminal.
Output of this command is the difference of recursive file lists in two directories (very quick!).
To view differences in content of files too, use the command submitted by mariusbutuc (very slow!):
diff -rq path_to_dir1 path_to_dir2
If you have ever edited a locally checked out version of a file to tweak it for testing purposes, and came back to it over a weekend, you might have forgotten what you exactly changed. This command helps you see the differences between the the checked in SVN version, and the one you tweaked.
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.
Requires wdiff. Prints the word-by-word diff with the old version highlighted in red, and the new in green. Change the colors by altering 41m and 42m. 45m is more of a magenta and may be easier to read.
Diffs two xml files by formatting them first using xmllint and then invoking diff.
Usage: diffxml XMLFile1 XMLFile2
Maybe very limited in its applicability but could be of use at times.
Upload/download newer version of any file with less size and high speed.
To remake the new file use
bspatch <oldfile> <newfile> <patchfile>