![]() |
|
|
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 |
| string replacement in a sequence of characters | raoscb | UNIX for Dummies Questions & Answers | 3 | 07-08-2008 07:00 AM |
| String Replacement Script | jbud | Shell Programming and Scripting | 6 | 11-15-2007 06:37 AM |
| String Replacement with Perl | Lindarella | Shell Programming and Scripting | 4 | 09-29-2006 03:05 PM |
| sed problem - replacement string should be same length as matching string. | amangeles | Shell Programming and Scripting | 4 | 01-11-2006 06:11 AM |
| String replacement in multiple files | WABonnett | Shell Programming and Scripting | 2 | 02-17-2004 03:49 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
AWK String replacement
I have an xml file with following tags
<NewTag>value123</xyz> <NewTag>value321</abcd> I have to replace the values in between the tags with some value ( VAL1/VAL2) but the thing the ending tag can be any thing, for this i need a awk command currently i am using this but it doesn't work ![]() awk -v n=$OCCURANCE -v s="<$TAGNAME>$TAGVALUE</$TAGNAME>" "/<$TAGNAME(.+)>/&&n==++c{sub(\"<$TAGNAME>(.+)>\",s)}1" $FILENAME the problem with this expression is the string s which i am building is a static one it doesn't take care of the changing ending tags!! can some one suggest me the proper expression? ![]() |
|
||||
|
what i exactly want to do is this
the xml file i need to change contains followin tags <Myproperty Name="Colour">RED</Myproperty> <MyName NickName="ppp">MYName</MyName> you can see that the starting tag and ending tag are different! i need to get the following out put when i execute the command <Myproperty Name="Colour">GREEN</Myproperty> <MyName NickName="ppp">URName</MyName> hope it's clear? ![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|