In Linux, I have a parent folder with 22 folders of various names, each with a file of a particular name
asset.xml. Also in these folders are hundreds of other folders with
asset.xmlin them, but these are previous versions and I'm not interested in them. I need to search inside each file for 3 tags
"legend|assetID|name" and return the information inside these tags. They're usually on the same line so i think
Grep is ok.
What i've tried:
grep -nr -E "legend|assetID|name" . > /dir/to/the/ReportFile.txt
This takes way too long and return way too much duplicated data, so this isn't practical.
find . -maxdepth 2 -exec grep -E "legend|assetID|name" . > /dir/to/the/ReportFile.txt
This returned an error with -exec missing an argument, so the output file was empty.
find . -maxdepth 2 -| grep -E "legend|assetID|name" . > /dir/to/the/ReportFile.txt
This returned an empty output file.
Question: How do I go through each like-named file each inside various-named folders (which also have other subfolders with files of the same name) and extract information inside the 3 tags and write this data into an output file?