I'm confused with a seeming simple part of sed - the or statement. I wrote the following sed which parses an event file with multiple events encapsulated between event tags and then prints the output of each event on 1 line each:
machinename:~$ sed -n "/<event/,/<\/event>/ {/<result/{s/.*result value=\" \(.*\)\"\/>.*/\1/g; p}; /<sender/ {s/.*phoneNo=\"\(.*\)\" country.*/\1/g; p}}" xmlEventLog_2010-02-05T16:40:55.xml | sed '/Allowed/{N;s/\n/ /;}'
Allowed +989350000100
Allowed +989350000209
Allowed +989350000002
Allowed +989350000002
Allowed +989350000100
Allowed +989350000209
Allowed +989350000002
Allowed +989350000002
machinename:~$
From the above there are 8 events in the log all with result Allowed. Now the trouble is there could be more than one result value. Result values could be Blocked Modified or Allowed. I thought that (Blocked|Modified|Allowed) in the second sed would handle this but I got the following output:
machinename:~$ sed -n "/<event/,/<\/event>/{/<result/{s/.*result value=\"\(.*\)\"\/>.*/\1/g; p}; /<sender/ {s/.*phoneNo=\"\(.*\)\" country.*/\1/g; p}}" xmlEventLog_2010-02-05T16:40:55.xml | sed '/(Allowed|Blocked|Modified)/{N;s/\n/ /;}'
Allowed
+989350000100
Allowed
+989350000209
Allowed
+989350000002
Allowed
+989350000002
Allowed
+989350000100
Allowed
+989350000209
Allowed
+989350000002
Allowed
+989350000002
machinename:~$
So what am I missing? why does the or in the final sed stop the newline replacement?
Thanks in advance
A