![]() |
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 |
| awk find/replace | RobertSubnet | Shell Programming and Scripting | 2 | 03-08-2009 01:45 PM |
| Find and Replace in ksh. | gauravsunil | Shell Programming and Scripting | 1 | 12-05-2008 07:55 AM |
| find and replace | javeed7 | Shell Programming and Scripting | 1 | 04-02-2008 09:00 AM |
| find replace | dbsurf | Shell Programming and Scripting | 2 | 01-25-2008 08:39 AM |
| find and replace | mahabunta | UNIX for Dummies Questions & Answers | 7 | 09-21-2006 12:05 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
find and replace and keep
Hi All
I've file in which has these lines in it create fil23456 read on 3345 create fil23456_1 read on 34567 create fil23456_2 read on 36789 I'm trying to replace the lines in such a way that in the end the file will look like create fil23456 read on 3345 alter fil23456 read on 34567 alter fil23456 read on 36789 I would like to replace the occurrences of _1, _2 (this can be many so i cant hardcode saying _1 and _2) I tried some of the sed, but couldnt succed (it is removing _ but not the 1s and 2s, then other one is reomving everything before _) Can someone please help. |
|
||||
|
i think this one works....
sed 's/\(_*\) *_./\1/' this will remove all the _s. I have to now get the replace ![]() Quote:
|
|
||||
|
Atlast i got suceeded with this
sed '/:*_./s/^/#/g; s/\(_*\) *_./\1/; s/#create filS*./alter filS/g' Input is this create fil23456 read on 3345 create fil23456_1 read on 34567 create fil23456_2 read on 36789 create fil26756 read on 56890 create fil26756_1 read on 37897 create fil26756_2 read on 67667 and this is the output create fil23456 read on 3345 alter filS3456 read on 34567 alter filS3456 read on 36789 create fil26756 read on 56890 alter filS6756 read on 37897 alter filS6756 read on 67667 Thanks a lot for all your help... |
![]() |
| Bookmarks |
| Tags |
| bash, sed |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|