If you are
xml files in this way then your search will return the entire line containing the search string and, if the
xml file has no newlines, the entire file contents. Quite a lot of "other" across 10M files.
As per @Kusalananda comment it isn't good practice to brute force an
grep and an
xml parser e.g.
xmllint is a better tool, however, if you insist ......
grep and read up on the
-o option to restrict the returned value and use
regex that defines the whole length of the match you are looking to find.
username is an attribute
grep -o 'username="[^"]*"'
xmllint --xpath "//@username"
username is a node then something like
grep -o "username>[^<][^<]*"
xmllint --xpath "//username"
With either of the
xmllint queries, just wrap the query in
string() to extract the attribute or node text.
xmllint --xpath "string(//username)"
xmllint --xpath "string(//@username)"