Useful for checking if there are differences between local and remote files.
bash/ksh subshell redirection (as file descriptors) used as input to diff
This command takes a snapshot of the open files for a PID 1234 then waits 10 seconds and takes another snapshot of the same PID, it then displays the difference between each snapshot to give you an insight into what the application is doing.
This uses Bash's "process substitution" feature to compare (using diff) the output of two different process pipelines.
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 Show Sample Output
You got some results in two variables within your shell script and would like to find the differences? Changes in process lists, reworked file contents, ... . No need to write to temporary files. You can use all the diff parameters you'll need. Maybe anything like $ grep "^>" is helpful afterwards.
:q to quit
Simple way to achieve a colored SVN diff
This can be much faster than downloading one or both trees to a common servers and comparing the files there. After, only those files could be copied down for deeper comparison if needed. Show Sample Output
Diffs two xml files by formatting them first using xmllint and then invoking diff. Usage: diffxml XMLFile1 XMLFile2
I've been looking for this for a long time. Does anybody know how to do this in dash (POSIX shell)?
An alternative version might be:
exiftool img_1.jpg | diff - <(exiftool img_2.jpg)
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. Show Sample Output
I sometimes (due to mismanagement!) end up with files in a git repo which have had their modes changed, but not their content. This one-liner lets me revert the mode changes, while leaving changed-content files be, so I can commit just the actual changes made.
Will colorize your svn diff.
If you like to view what has been changed between revision 100 and the BASE on FILE. Meld will give you a nice overview.
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
Use this to make a new commit that "softly" reverts a branch to some commit (i.e. squashes the history into an inverse patch). You can review the changes first by doing the diff alone.
Useful for massive files where doing a full diff would take too long. This just runs diff on the first 500 lines of each. The use of subshells to feed STDIN is quite a useful construct.
Sees if two records differ in their entries, irrespective of order.
commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.
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: