f78 Suppressing Lines Matching a Regular Expression

Contents|Index|Previous|Next

Suppressing Lines Matching a Regular Expression

To ignore insertions and deletions of lines that match a regular expression, use the '-I regexp' or '--ignore-matching-lines= regexp' option. You should escape regular expressions that contain shell meta-characters to prevent the shell from expanding them.

For example, 'diff -I 'ˆ[0-9]'' ignores all changes to lines beginning with a digit.

However, '-I' only ignores the insertion or deletion of lines that contain the regular expression if every changed line in the hunk—every insertion and every deletion—matches the regular expression.

In other words, for each non-ignorable change, diff prints the complete set of changes in its vicinity, including the ignorable ones.

You can specify more than one regular expression for lines to ignore by using more than one '-I' option. diff tries to match each line against each regular expression, starting with the last one given.

For more documentation, see the following.

0