So, I'm back with another, pretty much similar question. I've got a catalogue, with about 60k text files. Every file contains a single line of text with variable number of characters. Here are some examples, which will make my case easier to understand:
Example file 1.
[...]<item id="2506"/><item id="3000"/><item id="2506"/><item id="3000"/>[...]
Example file 2.
[...]<item id="2506"/><item id="3000"/><item id="3000"/><item id="3000"/>[...]
Example file 3.
[...]<item id="3000"/><item id="3000"/><item id="3000"/><item id="3000"/>[...]
Example file 4.
[...]<item id="2506" special_description="blablabla"/>[...]
Example file 5.
[...]<item id="2506" special_description="lololol"/>[...]
And I've got two issues.
Issue 1. I'd like to know how many '<item id="2506"/>' records do I have in the catalogue, with specific filenames added. So in the example case I'd print something like:
example file 1 name
example file 1 name
example file 2
Since Example file 1 contains the string two times, example file 2 contains only a single record, and 3,4,5 doesn't. Is it possible to do?
Issue 2. I'd like to find every record of <item id="2506" that has the special_description in it's arguments, and print out the special_description value.
I'd see it like this:
Filename(example file4) and here printed out the x characters after the <item id="2506", so I'd see the special_description. Final output:
example file 4 special_description="blablabla"
example file 5 special_description="lololol"
I'm sorry if it's a little chaotic. I've tried different arguments of grep, but failed at both cases.
Cheers.