Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== diff ====== * compare files in two directories, don't show common lines, output in 2 columns and ignore white space differences<code> diff -y -b --suppress-common path1 path2 </code> * compare all files recursively, excluding any with a .pdf extension, and only print file names that differ<code> diff -r -q --exclude="*.pdf" path1 path2 </code> * compare all files recursively, excluding any with a .pdf extension, and only print file names that differ, but suppress common subdirectory and Only in lines<code> diff -r -q --exclude="*.pdf" path1 path2 | grep -v -E '^Common subdirectories|^Only in' </code> ===== alternative output formats ===== * unified<code> diff --unified file1.txt file2.txt </code> * context<code> diff --context file1.txt file2.txt </code> ===== create patch file ===== * diff -Naur oldfile newfile > patchfile * then, to patch an original, copy the patchfile beside the file to be updated, and patch it like this<code> patch -p0 < patchfile </code> ===== count lines that are different ===== This outputs 2 columns, hiding lines that are the same, then pipes the result through the wc program with the flag to count newlines. <code> diff -y --suppress-common-lines file1.txt file2.txt | wc -l </code> ===== help ===== The diff utility has a man page, but the more comprehensive documentation is available in info format (info diff). docs/unix/diff.txt Last modified: 2016/03/27 22:44by billh