Re: diff command ignoring question
- From: marrgol <marspamrgol@xxxxxxxxxxxxx>
- Date: Thu, 26 Jan 2012 19:40:16 +0100
On 2012-01-24 15:21, Bit Twister wrote:
May not work on all distributions.
$ diff -I this -I that a a1
$ diff -I '\(this\)\|\(that\)' a a1
$ cat a
$ cat a1
Works fine. Check again what exactly -I does and remember that
diff works with "hunks", which means it doesn't necessarily compare
line 21 from one file to line 21 from the other. In your example
all three lines differ and diff arbitrarily chooses line "that"
to be the common line of a hunk, and this happens to be line 2
in file "a" but line 1 in "a1".
So here diff processes like this: line "this" needs to be removed
from "a" to match "a1" but since it matches the pattern specified
by -I, ignore it. Line "that" stays untouched, ignore it.
Line "good" needs to be removed from "a" to match "a1", show it.
Lines "this" and "bad" need to be inserted. Although line "this"
should be ignored because it matches the pattern specified
by -I, the very next line, "bad", doesn't match and thus
cannot be ignored, so need to show them both because "for each
nonignorable change, `diff' prints the complete set of changes
in its vicinity, including the ignorable ones." (see 'info diff')
Change "bad" to "good" in "a1" and see that the changes in the first
two lines will be ignored.
- Prev by Date: Re: Why are mkisofs ISO's so large?
- Next by Date: Re: diff command ignoring question
- Previous by thread: Re: diff command ignoring question
- Next by thread: Re: diff command ignoring question