Difference between revisions of "Diff"
Jump to navigation
Jump to search
(Created page with "On unix systems find differences between 2 files ;diff file1 file2 ;diff -u file1 file2 :Report all differences between the files :Lines starting with < (-) need to be remove...") |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | [[Category:Linux/Unix]] | ||
On unix systems find differences between 2 files | On unix systems find differences between 2 files | ||
;diff file1 file2 | ;diff file1 file2 | ||
+ | :Show differences between the 2 files | ||
+ | ;diff -b file1 file2 | ||
+ | :Ignore space changes | ||
;diff -u file1 file2 | ;diff -u file1 file2 | ||
+ | ;diff -U <num> file1 file2 | ||
:Report all differences between the files | :Report all differences between the files | ||
:Lines starting with < (-) need to be removed and starting with > (+) need to be added to go from file1 to file2 | :Lines starting with < (-) need to be removed and starting with > (+) need to be added to go from file1 to file2 | ||
+ | : <code>-u -U</code> also report some lines before and after the actual difference (the context) (default 3) with <code>-U <num></code> you can specify the number of context lines. |
Latest revision as of 10:16, 24 April 2023
On unix systems find differences between 2 files
- diff file1 file2
- Show differences between the 2 files
- diff -b file1 file2
- Ignore space changes
- diff -u file1 file2
- diff -U <num> file1 file2
- Report all differences between the files
- Lines starting with < (-) need to be removed and starting with > (+) need to be added to go from file1 to file2
-u -U
also report some lines before and after the actual difference (the context) (default 3) with-U <num>
you can specify the number of context lines.