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:
A great command to assign to an alias, allowing you to git diff the last two commits in git.
opens the output of some command as a file so this also works with graphical editors like meld, kdiff3 etc
meld <(ssh $remote_site cat .zshrc) .zshrc
For editing files added to the index:
vim `git diff --name-only --cached`
To edit all changed files:
vim `git diff --name-only HEAD`
To edit changed files matching glob:
vim `git diff --name-only -- '*.html'`
If the commands needs to support filenames with whitespace, it gets a bit hacky (see http://superuser.com/questions/336016/invoking-vi-through-find-xargs-breaks-my-terminal-why for the reason):
git diff --name-only -z | xargs -0 bash -c '</dev/tty vim "$@"' x
The last part can be put in a script named e.g. vimargs, and used with any command outputting NUL separated filenames:
git grep -lz foobar | vimargs
from a svn repo, print a log, with diff, of each commit touching a given file
Copy changed files from remote git repository, _including binary ones_, staged and unstaged alike. Note that this command doesn't handle deleted files properly.
When running a long `diff -r` over folders, this simulates a "verbose" mode where you can see where diff is in the tree.
Replace $file with the first part of the path being compared.
With this command, you can check the difference between the volumes mounted and the volume in /etc/fstab.
Tested in bash4
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!
Branch name may be substituted, of course.
This is usefull to diff 2 paths in branches of software, or in different versions of a same zip file. So you can get the real file diff.
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.
Get the list of changed files between revision 43 and HEAD revision: svn diff . -r43:HEAD --summarize
Strip extra 8 characters from every line: cut -c9-99999
Copy the listed files to home/me/destination: cpio -pvdmu ~/destination
Make a plain copy (-p), list files being copied (-v), create needed directories (-d), preserve modification time (-m), overwrite unconditionally (-u)
Good for when your working on building a clean source install for RPM packaging or what have you. After testing, run this command to compare the original extracted source to your working source directory and it will remove the differences that are created when running './configure' and 'make'.