When I execute the command
echo '<test>' | sed -e 's/<\(.*\)>/\1/g'
I get the string
test
returned. When I execute the command
echo 'Jun 10 13:23:16 server /opt/app/introdedaemon/sbin/mq2init[14150]: Debug 1433935396.995245: (XMLRPCConnector.cpp)(MQMessage)(98)[domt initrode.om]: encoded string: <aGVyZSBpcyBub3RoaW5n c3RpbGwgbm90aGluZw== > (size 908)' | sed -e 's/<\(.*\)>/\1/g'
I would expect to get the string
aGVyZSBpcyBub3RoaW5n c3RpbGwgbm90aGluZw==
returned, but instead I get the string
Jun 10 13:23:16 server /opt/app/introdedaemon/sbin/mq2init[14150]: Debug 1433935396.995245: (XMLRPCConnector.cpp)(MQMessage)(98)[domt initrode.om]: encoded string: aGVyZSBpcyBub3RoaW5n c3RpbGwgbm90aGluZw== (size 908)
back. Why does this happen and with which regex can I return the part between the "<" and ">" for the string
Jun 10 13:23:16 server /opt/app/introdedaemon/sbin/mq2init[14150]: Debug 1433935396.995245: (XMLRPCConnector.cpp)(MQMessage)(98)[domt initrode.om]: encoded string: <aGVyZSBpcyBub3RoaW5n c3RpbGwgbm90aGluZw== > (size 908)
?
You need to use:
as there is a text before
<
and after>
also.This will give output as:
You can get same output using this much simpler
awk
command also: