Open main menu

Changes

1,547 bytes added ,  15:10, 15 May 2017
add quick directory comparison
diff -rq -x .svn ./work/myproject/ ./work/myproject-copy2/
</source>
 
=== Piping ===
 
The <code>diff</code> command is fast, but often the output is hard to read to find the exact difference. You might try piping the output of the diff command to a graphical tool:
<source lang="bash">
diff fileA fileB | kdiff3 -
</source>
By using the dash option to kdiff3, you're telling it to read from STDIN, so it uses the output of the former commands being piped to it.
 
 
Or, piping to <code>awk</code> to print a list of just what's in the 'left side'.
<source lang="bash">
diff --suppress-common-lines --side-by-side modules.list.a.txt modules.list.b.txt |awk '{print $1}'
</source>
 
=== Process Substitution ===
By using process substitution, we can operate on the output of commands without the need for saving to a file.
<source lang="bash">
drush pml --status=enabled --pipe > modules.list.txt
# make a bunch of changes to what modules are enabled, perhaps restoring from a backup, and compare to our original list
 
diff --suppress-common-lines --side-by-side <(drush pml --status=enabled --pipe) modules.list.txt
</source>
 
This technique comes in handy if you wish to compare two directories at their top level. The '''extensions''' directory, for example, in [[MediaWiki]] from two different installations:
<source lang="bash">
diff --suppress-common-lines --side-by-side <(ls -1 /var/www/wiki.example.net/www/w/extensions/) <(ls -1 /var/www/wiki.example.org/www/w/extensions/)
</source>
 
 
=== Compressed files ===
<code>zdiff</code> is a tool that can be used directly on compressed files (like zcat, zgrep, etc.)
 
== KDiff3 ==
4,558

edits