Hi weknowd,
Note that according to post #1 in this thread, the desired output included the header that was present in both input files, while the output produced by:
grep -vf file2 file1
deleted the header line. Note also that if the ID values are of varying lengths and one of the IDs in file2
to be removed from the master file ( file1
) also appears as a substring of another ID or appears in the NAME field, the suggested code may remove additional lines that have IDs that are not included in file2
. For example, if file1
contained:
ID,NAME
123,Jane Doe
2,John Doe
312,Jack Smith
421,Jim Taylor
567,Fred Zahn
and file2
contained:
ID
2
3
the given code will not only remove the header line, a line with ID 2, and a line with ID 3; it will also remove lines with IDs 12, 21-29, 32, 42, ... and lines with IDs 13, 23, 31, 33-39, 43, ....; i.e., the results would only be:
456,Fred Zahn
not:
ID,NAME
123,Jane Doe
312,Jack Smith
421,Jim Taylor
567,Fred Zahn
With your problem statement, we have no idea whether or not the code drl suggested works for real data you may need to process or just works for the sample data you provided.