Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Substitution String Help

Status
Not open for further replies.

campbere

Technical User
Oct 10, 2000
146
US
Hello,

I have an xml document that has one too many end tags in over 500 documents. I want to eliminate one of the end tags and thought I would use it with a substitution line. However I have been unsuccesful.

example of text:

</body>
</prod_batch>
</prod_batch>

I wrote:
perl -pi -e &quot;s#</prod_batch>\n</prod_batch>#</prod_batch>#g *.xml

Can someone help?
 
I think you need an 's' switch on the end of your statement.
The default behavior for Perl regexes is to treat each line separately. The 's' switch turns the entire file into one string.

$var =~ s/find this/replacement text/[red]s[/red]g; 'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top