I’m probably missing something really obvious but I have an xml file that I need to grep to see if it contains this:
<phone>null</phone>
or
<phone></phone>
In any case, and with any additional spaces (between the tags).
So, my non working solution is this:
grep -i "\<phone\>\s*(null)?\s*\</phone\>" ./myfile.xml
But that returns empty (even though the file I’m using has this node).
What am I overlooking?
TIA
Ah! Found it… I’ll answer it myself in case anyone else finds it useful in the future… adding the -P switch ie…
…to the call makes it use perl style regex (which is what I’m using) and produces the desired result.