I am just starting out using sed
and I intend to use it to extract IP addresses from ping
output. Here's what I am trying to achieve exactly:
input text:
ytmti (192.188.2.3) jjggy
desired output:
192.188.2.3
command I am trying:
echo "ytmti (192.188.2.3) jjggy" | sed 's:\((\(192.188.2.3\))\):\2:'
current output:
ytmti 192.188.2.3 jjggy
Note: ytmti
and jjggy
are really stand-ins for text like Pinging unix.stackexchange.com
and with 32 bytes of data:
.
I think using awk
might be a better solution for parsing ping
output,
but I would like to get accustomed to sed
.
Note:...etc
above was inserted by others and does not accurately reflect the question as it was first asked. Whether it accurately reflects op's original intent i cannot say, but it was certainly added after the question was asked. Please see this meta question about it. – mikeserv Jun 24 '14 at 17:45