![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| find and replace and keep | Celvin VK | Shell Programming and Scripting | 3 | 04-03-2009 02:34 PM |
| awk find/replace | RobertSubnet | Shell Programming and Scripting | 2 | 03-08-2009 01:45 PM |
| find and replace | javeed7 | Shell Programming and Scripting | 1 | 04-02-2008 10:00 AM |
| find and replace | rakshit | Shell Programming and Scripting | 4 | 01-24-2008 03:52 AM |
| find and replace | valhutch | UNIX for Dummies Questions & Answers | 4 | 07-29-2006 06:20 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
find & incremental replace?
Looking for a way using sed/awk/perl to replace port numbers in a file with an incrementing number. The original file looks like...
Host cmg-iqdrw3p4 LocalForward *:9043 localhost:9043 Host cmg-iqdro3p3a LocalForward *:10000 localhost:10000 Host cmg-iqdro3p3b LocalForward *:10000 localhost:10000 ...... And I want to convert it to: Host cmg-iqdrw3p4 LocalForward *:9043 localhost:2062 Host cmg-iqdro3p3a LocalForward *:10000 localhost:2063 Host cmg-iqdro3p3b LocalForward *:10000 localhost:2064 ....... I used sed to convert 'localhost:xxxx' to 'localhost:'. In vi, I used the following to add back the incrementing port number. :let i=2000 | g/localhost:/s//\="localhost:".i/ | let i=i+1 Is there a way to do it all in sed? Sed, awk, perl or shell script answers would all be welcome too. Thanks. |
![]() |
| Bookmarks |
| Tags |
| sed awk bash shell |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|