diff [options] file1|- file2|-
-
specifies standard input.
diff directoryX file
Compare directoryX/file
with $PWD/file
No need to specify $PWD.
diff directory directory
--recursive
is given.
diff
does not compares the actual contents of a directory as if it were a file.
The file that is fully specified may not be standard input,
because standard input is nameless and the notion of "file with the same name" does not apply.
Use --
to terminate options when specifing file names which begin with a -
.
Multiple single letter options can be combined. Example: ‑wyW50
(whiteSpaceIgnored, sidebYside, width=50)
show lines in commoncomm
show bytes differingcmp
Side-by-side merge of file differences.sdiff
Options to
If there are only | |||||||||||
-i --ignore-case | |||||||||||
-B --ignore-blank-lines | Ignore differences that just insert or delete Blank lines | ||||||||||
-b | Ignore differences in amount of blanks | ||||||||||
-w | Ignore white space lines, including ␍␊ (0D0A ) verses  (0A alone) as in Apple Mac vs linux vs MSWindows.
| -I regexp
--ignore-matching-lines= regexp Ignore differences that just insert or delete lines that match | regexp .Option affecting amount of output
| -q --brief | q uite, do not show differences, only whether the files differ.Output " Files old-file and new-file differ " or nothing
Useful when comparing directories.
See
To check the return code diff --brief … xxx xxx' if [ $? -gt 0 ]; then echo -n $'\a ' ;fi #alert bell -t --expand-tabs to spaces in the output to preserve alignment.
| -T --initial-tab Output a Tab rather than a space before the text of a line in normal or context format, causes the alignment to look normal.
| |
|
|
Show the differences with some lines before and after the differences, i.e. in context.
diff -c dfdf1 dfdf2 *** dfdf1 Tue Sep 5 18:10:15 2006 ← mod date of file differs, line is prefixed with stars --- dfdf2 Tue Sep 5 18:10:24 2006 *************** ← seperator *** 4,7 **** ← position (column,line) where difference starts in dfdf1 1.3G /Volumes/PHOTOS_1 2.7G /Volumes/PHOTOS_2 56K /Volumes/BACKUP_2 ! 919M /Volumes/TBD ↖ position where difference starts ----4,7 ---- ← position (column,line) where difference starts in dfdf2 1.3G /Volumes/PHOTOS_1 2.7G /Volumes/PHOTOS_2 56K /Volumes/BACKUP_2 ! 898M /Volumes/TBD -e --ed Make output that is a valid ed script.7c 898M /Volumes/TBD .
diff -f dfdf dfdf_1 c7 898M /Volumes/TBD .
diff -n dfdf dfdf_1 d7 1 a7 1 898M /Volumes/TBD
|
--sdiff-merge-assist
Print extra information to help sdiff. sdiff uses this option
when it runs diff. This option is not intended for users to use directly.
-d
--minimal
Change the algorithm to perhaps find a smaller set of changes.
slower (sometimes much slower).
-H
--speed-large-files
Use Heuristics to speed handling of large files that have numerous scattered small changes.
-s --report-identical-files | Report "are identical " when files are the same based on the data compared! otherwise no output is produced. | ||||||||||||
-q --brief | q uite, do not show differences, only whether the files differ.Output " Files old-file and new-file differ " or nothing
| ||||||||||||
-x pattern |
file1 file2 are identical
is output.
commCompare sorted files displaying lines in common.
With no options, produce three-column output.
> cat 1 aaaaaaaaa bbbbbbbb ccccccc > cat 2 aaaaaaaaa b222bbbb ccccccc > comm 1 2 aaaaaaaaa b222bbbb bbbbbbbb ccccccc |
cmpShow characters/bytes differingcmp options file1 file2
Return values:
Errors:
> cat 1
aaa aaaaaa the space after aaa is due to a ␉ (i.e. Horizontal Tab, x'09')
bbbbbbbb
ccccccc
> cat 2
aaa aaaaaa
b222bbbb
ccccccc
>cmp 1 2
1 2 differ: char 13, line 2
>cmp --verbose F801191247/weather_station.dat F801191257/weather_station.dat | column -c140 -x # column across 76 245 75 77 1 24 78 127 203 79 75 274 80 263 200 81 76 70 82 221 170 83 261 156 84 323 337 85 6 23 86 347 324 87 164 34 88 154 247 89 147 217 90 131 111 91 37 334 92 222 30 93 267 375 94 57 232 95 366 227 96 244 367 97 0 10 98 314 14 99 203 365 100 326 272 101 116 352 102 244 71 103 35 16 104 202 270 105 56 102 106 341 357 107 372 125 108 124 114 109 143 253 110 217 61 111 223 166 112 3 342 113 263 331 114 141 367 115 325 164 116 135 341 117 47 352 118 200 72 119 34 266 120 170 116 121 261 107 122 6 54 123 73 23 124 37 121 125 324 173 126 171 125 127 252 3 128 16 21 129 123 101 130 16 313 131 306 257 132 175 77 133 10 125 134 66 175 135 253 167 136 153 1 137 204 27 138 264 162 139 245 13 |
sdiffside-by-side merge of file differences sdiff [option]… file1 file2
If one of | ||||||||||||||||||||||||||||||||||||||
Ignore minor differences | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
-i |
bdiff { filename1 | - } { filename2 | - } [ number ] [ -s ] splits files into number pieces and the call diff
|