Pattern manipulation in korn shell script using sed.

Hi,

Could any one let me know, how can I cut the last field in below mentioned line.

net,-hopcount,0,-netmask,255.255.255.0,,,,,192.168.37.0,10.253.0.1
net,-hopcount,0,-netmask,255.255.255.0,,,,,192.168.1.0,10.253.0.1 net,-hopcount,0,-netmask,255.255.255.0,,,,,192.168.38.0,10.253.0.1
net,-hopcount,0,-netmask,255.255.255.0,,,,,192.168.2.0,10.253.0.1
net,-hopcount,0,-netmask,255.255.255.0,,,,,192.168.39.0,10.253.0.1
net,-hopcount,0,,0,10.14.185.1
net,-hopcount,0,-netmask,255.255.255.0,,,,,0,10.14.185.1
net,-hopcount,0,-netmask,255.255.0.0,,,,,10.253.0.0,10.253.0.1
net,-hopcount,0,-netmask,255.255.255.0,,,,,192.168.9.0,10.253.0.1
net,-hopcount,0,-netmask,255.255.255.0,,,,,192.168.36.0,10.253.0.1

I want to get all the gate way mentioned in bold above., ie last 10.253.0.1. we can't use the filed separator as " , " while using awk as the number of parameter varies. Tried all awk but hope can do it using sed. would like to know the format.

Thanks,
Ajilesh

With awk you can get the last field with $NF:

awk -F, '{print $NF}' file

Regards

Try this..

$ awk -F"," '{ print $NF }' <<File name >>

It works...!! Great..!!