x360x chaos
New Member
I have a XML file that looks like this:\[code\]<Group> <Name>Awesome Group</Name> <Notes /> <Date>2013-04-04</Date> <Expires>False</Expires> <Icon>7</Icon> <Tags /></Group>\[/code\]I'm trying to print everything between \[code\]<Notes />\[/code\] and \[code\]</Icon>\[/code\] with this command:\[code\]$ sed -n '/\<Notes \/\>/ p' file.xml\[/code\]Notice I'm escaping the open and close brackets as well as the forward slash before the close bracket. This returns no matches, which I find odd.What's even more odd is that this command works:\[code\]$ sed -n '/<Notes \/>/ p' file.xml\[/code\]Why does this command work, since I'm not escaping the open and close brackets?EDITruakh helpfully pointed out that there are different implementations of sed, and that open and close brackets don't need to be escaped (I thought sed used Perl syntax for regular expressions). I found another post on Unix & Linux that was also helpful: http://unix.stackexchange.com/quest...-need-to-escape-when-using-sed-in-a-sh-scriptNow I'm having a problem matching a multi-line regular expression. How come this doesn't work?\[code\]$ sed -n -r '/^<Notes \/>[\S\s]*?<\/Icon>$/ p' file.xml\[/code\]I've tried with and without the \[code\]-r\[/code\] (extended mode), with and without the \[code\]^\[/code\] and \[code\]$\[/code\], using \[code\].*\[/code\] instead of \[code\][\S\s]*\[/code\], all with no matches