![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Korn Shell script not running | Asty | Shell Programming and Scripting | 1 | 08-11-2006 10:17 AM |
| Help with Korn Shell script | heprox | AIX | 1 | 12-19-2005 11:04 AM |
| korn shell script | pavan_test | UNIX Desktop for Dummies Questions & Answers | 3 | 10-27-2005 09:09 AM |
| korn shell script | pavan_test | UNIX for Dummies Questions & Answers | 1 | 10-26-2005 10:17 AM |
| shell script : text manipulation (easy quesiton) | champion | Shell Programming and Scripting | 3 | 07-01-2002 12:10 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
With awk you can get the last field with $NF:
Code:
awk -F, '{print $NF}' file
|
|
#3
|
|||
|
|||
|
Try this..
$ awk -F"," '{ print $NF }' <<File name >> |
|
#4
|
|||
|
|||
|
It works...!! Great..!!
|
|||
| Google The UNIX and Linux Forums |