I have a file where each line is a base64-encoded XML document. The decoded XML documents may contain new line characters. I would like to grep out each XML document containing a given word.
The problem is that, when I decode the lines of the file, I have multiple lines for each base64-encoded line and I cannot grep it any more. I need something like base64 decode + remove line breaks
in one step.
How can I achieve that in the Linux shell? I have Python, Perl and awk available.
>cat fileContainingBase64EncodedXMLsInEachLine.txt | what should I write here?
Input:
PGZvbz4NCjxiYXIvPg0KPC9mb28+
PGZvbz4NCjxodWh1Lz4NCjwvZm9vPg==
PGZvbz4NCjxiYXJvbWV0ZXIvPg0KPC9mb28+
Expected Output
Let's say I want the XML documents containing 'bar'
<foo>
<bar/>
</foo>
<foo>
<barometer/>
</foo>
An example for my problem
>cat fileContainingBase64EncodedXMLsInEachLine.txt | base64 --decode | grep bar
Delivers:
<bar/>
<barometer/>
So I do not have the full xml documents containing bar
and barometer
.