![]() |
|
|
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 |
| Getting the lines between last occurrence of two patterns | rvz | Shell Programming and Scripting | 8 | 08-08-2008 06:32 PM |
| SED replace string by occurrence | uttamhoode | Shell Programming and Scripting | 4 | 03-05-2008 05:04 AM |
| awk + last occurrence | agibbs | UNIX for Dummies Questions & Answers | 2 | 10-06-2007 04:32 PM |
| Search and replace to first occurrence of string | gilmord | UNIX for Dummies Questions & Answers | 7 | 05-03-2006 08:43 AM |
| Grep for the same occurrence or maybe Sed | hcclnoodles | Shell Programming and Scripting | 4 | 09-12-2002 01:25 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
|
||||
|
Replace second occurrence only
HPUX /bin/sh (posix)
I have a file as such cat dog mouse deer elk rabbit mouse rat pig I would like to replace the second occurrence of mouse in this file with mouse2. The rest of the file has to stay exactly as is. I'm not sure exactly where mouse might be (could be first,second,third field). TIA!!!!!! |
|
||||
|
the poster said they wanted the second occurrence. this does that. if you need all occurrences of mouse changed on the line where the second occurrence is found then change sub to gsub.
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|