![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | 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 |
| Search, replace string in file1 with string from (lookup table) file2? | gstuart | Shell Programming and Scripting | 2 | 04-11-2008 11:32 AM |
| Replace second occurrence only | lyoncc | Shell Programming and Scripting | 5 | 12-26-2007 07:21 PM |
| last occurrence of a string across multiple files | porphyrin | UNIX for Dummies Questions & Answers | 2 | 12-24-2007 05:39 AM |
| delete string in a text file leaving the first occurrence | gopskrish | UNIX for Dummies Questions & Answers | 12 | 10-31-2006 06:32 AM |
| Search and replace to first occurrence of string | gilmord | UNIX for Dummies Questions & Answers | 7 | 05-03-2006 04:43 AM |
|
|
LinkBack | Thread Tools | 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 |
| Forum Sponsor | ||
|
|
|
|||
|
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. |