in reply to Re^2: How to know if two files (.c,.h,.cpp) are different content-wise ignoring the comments?
in thread How to know if two files (.c,.h,.cpp) are different content-wise ignoring the comments?

Um, what? man diff
  • Comment on Re^3: How to know if two files (.c,.h,.cpp) are different content-wise ignoring the comments?

Replies are listed 'Best First'.
Re^4: How to know if two files (.c,.h,.cpp) are different content-wise ignoring the comments?
by iphone (Beadle) on Feb 13, 2011 at 08:38 UTC

    I am trying to use diff tool but use the -I option to ignore lines that start with "File Name:".i am using the below regular expression,there is no syntax error but the diff tool still shows changes with line that starts with "File Name:".Any idea what is going wrong?

    diff -I '[^\s*File\sName:]' file1 file2

      iphone:

      If there are differences in comments, then it's likely that there will be differences in the whitespace as well, so tell diff to ignore blank lines and other forms of whitespace. I don't know what you're running on, but on my box here, I use the options:

      • -E to ignore tab expansion
      • -b to ignore changes in whitespace
      • -w to ignore all whitespace
      • -B to ignore blank lines

      Note: I've never experimented to see if I can get by with a subset of those flags, but I suspect I can. But it's easy, so I've never found it worth the time to find out.

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

      Where does Perl come into play here?