| Flag | Usage |
|---|---|
| -b --ignore-space-change | ignore changes in the amount of white space |
| -B --ignore-blank-lines | ignore changes where lines are all blank |
| -c n | output n (default : 3) lines of context (details) |
| -i --ignore-case | ignore case in file content (don't mix this option up with --ignore-file-name-case) |
| -q --brief | list only name of files having differences |
| -r | compare files recursively when file1 and file2 are directories. |
| --suppress-common-lines | Do not output common lines. |
| -u n -U n | output n lines of unified context (n defaults to 3) (details) |
| -w --ignore-all-space | ignore all white space |
| -W n --witdh=n | Display at most n print columns (defaults to 130, see tput cols) |
| -x pattern --exclude=pattern | ignore files matching pattern |
| -y --side-by-side | output in 2 columns |
| -Z --ignore-trailing-space | ignore white space at line end |
fileA='inventory_CW_STG_PCK.ini' fileB='inventory_FE_BCR.ini' diff --color=always --suppress-common-lines -Bbiy -W $(tput cols) "$fileA" "$fileB" | less -R
| character | usage |
|---|---|
| (nothing) | no difference, just showing the line for context |
| | | difference found between line of file1 (left) and line of file2 (right) |
| < | only in file1 |
| > | only in file2 |
| ( | only in file1 but ignored |
| ) | only in file2 but ignored |
coconut | carrot
duku <
3c3 < coconut --- > carrotexplanations :
| output | usage | detail |
|---|---|---|
| a | add | nam : after line n of file1, add line m of file2 |
| c | change | ncn : change line n of file1 into line n of file2 |
| d | delete | ndm : delete line n of file1 so that file1 and file2 match at line m |
< lines of file1 --- separator > lines of file2
3a4 > dukuIn file1, after line 3, add the shown line so that it matches line 4 of file2
4d3 < dukuIn file1, delete line 4 shown below, so that it matches line 3 of file2
*** /tmp/tmp.xn4tkVqjXD 2021-02-03 08:54:11.000000000 +0100 --- /tmp/tmp.BpdMjolQIN 2021-02-03 08:54:11.000000000 +0100 *************** *** 1,3 **** apple banana - coconut --- 1,2 ----
*** /tmp/tmp.OUTUkSkX5Z 2021-02-03 08:58:43.000000000 +0100 --- /tmp/tmp.IsEgTXzyuc 2021-02-03 08:58:43.000000000 +0100 *************** *** 1,3 **** apple banana ! coconut --- 1,4 ---- apple + apricot banana ! carrot
what to do to file1 to make it look like file2:
--- /tmp/tmp.rxfT2dhbd7 2021-02-03 09:09:56.000000000 +0100 +++ /tmp/tmp.G8Ql2Fp4fy 2021-02-03 09:09:56.000000000 +0100 @@ -1,3 +1,3 @@ apple banana -coconut +carrotThis outputs differences with line / range and +, -, , like git diff does.