Imagine file 1:
#include "first.h"
#include "second.h"
#include "third.h"
// more code here
...
Imagine file 2:
#include "fifth.h"
#include "second.h"
#include "eigth.h"
// more code here
...
I want to get the headers that are included in file 2, but not in file 1, only those lines.
So, when ran, a diff of file 1 and file 2 will produce:
#include "fifth.h"
#include "eigth.h"
I know how to do it in Perl/Python/Ruby, but I’d like to accomplish this without using a different programming language.
If it’s ok to use a temp file, try this:
This
file1.hand writes them to the file/tmp/xfile2.hthat are not contained in this listfile2.hIt probably doesn’t handle differences in whitespace correctly etc, though.
EDIT:
to prevent false positives, use a different pattern for the last grep (thanks to jw013 for mentioning this):