![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| Search, replace string in file1 with string from (lookup table) file2? | gstuart | Shell Programming and Scripting | 9 | 06-08-2009 06:11 AM |
| Replace second occurrence only | lyoncc | Shell Programming and Scripting | 5 | 12-26-2007 11:21 PM |
| last occurrence of a string across multiple files | porphyrin | UNIX for Dummies Questions & Answers | 2 | 12-24-2007 09:39 AM |
| delete string in a text file leaving the first occurrence | gopskrish | UNIX for Dummies Questions & Answers | 12 | 10-31-2006 10:32 AM |
| Search and replace to first occurrence of string | gilmord | UNIX for Dummies Questions & Answers | 7 | 05-03-2006 07:43 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
SED replace string by occurrence
hi all,
I have a text file with following content PAGENUMBER asasasa asasasa PAGENUMBER sasasasasa PAGENUMBER using sed i want to replace PAGENUMBER by occurrence count eg 1 asasasa asasasa 2 sasasasasa 3 Thanks and Regards, uttam hoode |
|
||||
|
Quote:
cat $filename | awk '/PAGENUMBER/{count++; { sub("PAGENUMBER",count, $0)}; }; {print }' A part of this command is taken from a similar post by lyoncc, thanks to lyoncc. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|