This only works in bash
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.
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'...
Show Sample Output
jq is amazing for manipulating json on the commandline, but the developers have some weird ideas about how to handle shell redirections. This command works around them. Further reading: https://github.com/stedolan/jq/issues/1110
It can be hard to spot differences in reformatted files, because of all the diff noise created by word wrapped lines. This command removes all the noise and performs a word-by-word diff. To ignore empty lines, add -B to the diff command. Also, if this is something you do often, you might want to check out the wdiff(1) program.
diff is designed to compare two files. You can also compare directories. In this form, bash uses 'process substitution' in place of a file as an input to diff. Each input to diff can be filtered as you choose. I use find and egrep to select the files to compare.
A x509 certificate and a rsa key file have in common a parameter called modulus, it is a very long hexadecimal number. That value is unique for each certficate / key pair. The command allows to do the check of this pair of values in a script using a great feature of bash. " Show Sample Output
Figures out what has changed in the last 12 hours. Change the author to yourself, change the time since to whatever you want. Show Sample Output
Sometimes you need to compare two config files on different servers. Put the file names into the above script and let 'er rip.
You can compare directories on two different remote hosts as well:
diff -y <(ssh user1@host1 find /boot|sort) <(ssh user2@host2 find /boot|sort)
To avoid password-prompt on remote host just generate the rsa key locally and copy it to remote host:
ssh-keygen -t rsa
then
ssh you@server1 "mkdir .ssh"
then
scp .ssh/id_rsa.pub you@server1:; .ssh/authorized_keys2
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
Show Sample Output
I put this in a shell script called "svndiff", as it provides a handy decorated "svn diff" output that is colored (which you can't see here) and paged. The -r is required so less doesn't mangle the color codes. Show Sample Output
Lists revisions in a Subversion repository with a timestamp that doesn't follow the revision numbering order. If everything is OK, nothing is displayed.
Handy when you need to create a list of files to be updated when subversion is not available on the remote host. You can take this tar file, and upload and extract it where you need it. Replace M and N with the revisions specific to yours. Make sure you do this from an updated (svn up) working directory.
Makes sure the contents of "myfile" are the same contents that the author intended given the author's md5 hash of that file ("c84fa6b830e38ee8a551df61172d53d7").
**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 Show Sample Output
I've been using colordiff for years. wdiff is the new fav, except its colors. Word delimited diffs are more interleaved, easing the chore of associating big blocks of changes.
Tested in bash4
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: