I have a text file IDs.txt
containing one unique ID string per line e.g.:
foo
bar
someOtherID
I know that some of these IDs are found in one or both of 2 other files with differently formatted data lines, 1.txt
and 2.txt
1.txt
id=foo
name=example
age=81
end
id=notTheIDYouAreLookingFor
name=other
age=null
2.txt
<Data>
<ID>foo</ID>
<Stuff>Some things</Stuff>
</Data>
<Data>
<ID>bar</ID>
<Stuff>Other things</Stuff>
</Data>
The specific data formats are not important since all I need to answer is "which IDs are in both?", and indeed ideally I need a format-independent solution
In the example I want to find the lines with foo
:
<ID>foo</ID>
id=foo
Effectively: this question but grepping the large list of IDs against 2 files instead of 1 and finding the common hits.