Parse Line Using Sed

Hello All,

I am new to using sed, and I need to extract from the string data after : delimeter.

Can you help me please with the sed command?

Here's the input:
ipAddress: 10.20.10.11
ioIpAddressNodeB: 10.20.10.10
ioIpAddressNodeA: 10.20.10.9
ipAddress: 0.0.0.0

Expected Output:
10.20.10.11
10.20.10.10
10.20.10.9
0.0.0.0

Thanks in advance to anyone who'll reply.

Regards,
racbern

sed 's/.*://g'

should do you

or use awk:

awk '{FS=":";print $2}'

HTH

Here is one way of doing what you want using sed.

sed -n 's/^.*: \(.*$\)/\1/p'  yourfile

BTW, awk is probably a simpler tool to use for this type of task.

awk '{ print $2 }' yourfile

you forgot the FS definition:

awk -F: '{ print $2 }' yourfile

Actually no. The -F: option is not required because of the space after the colon on each line.

shell

#!/bin/sh
while IFS=: read one two
do
    echo $two
done < file

output:

# ./test.sh
10.20.10.11
10.20.10.10
10.20.10.9
0.0.0.0

awk -F: '{print $2}' file

cut -d: -f2 filename