The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
In Help, Substitute Text ... solidhelix08 Shell Programming and Scripting 6 02-07-2008 01:21 AM
Substitute Variable mmg2711 UNIX for Dummies Questions & Answers 0 10-26-2007 03:59 AM
Substitute File name vanand420 Shell Programming and Scripting 22 03-13-2007 10:40 PM
Substitute in vi kingdbag UNIX for Dummies Questions & Answers 5 01-17-2007 10:42 AM
sed substitute situation newbreed1 UNIX for Dummies Questions & Answers 16 06-03-2005 11:26 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-10-2008
Registered User
 

Join Date: Jun 2008
Location: England
Posts: 6
Stumble this Post!
Using SED to substitute between two patterns.

Hi All,

I'm currently using SED to make various changes to some .xml files I'm working on, but I'm stuck on this particular problem.

I want to remove '<placeholder>element-name</placeholder>' from the following:

<heading>Element <placeholder>element-name</placeholder> not recognized</heading>

This type of pattern is repeated in several of my files so essentially I'm looking to remove the placeholder tags and whatever is enclosed.

Any help greatly appreciated.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-10-2008
in2nix4life's Avatar
Registered User
 

Join Date: Oct 2007
Location: East Coast
Posts: 44
Stumble this Post!
If you have access to Perl, this should point you in the right direction:

perl -pe 's/(.*)<placeholder>.*<\/placeholder>\s(.*)/$1$2/g' file.xml

Returns:
<heading>Element not recognized</heading>

Hope this helps.
Reply With Quote
  #3 (permalink)  
Old 06-10-2008
Registered User
 

Join Date: Jun 2008
Location: England
Posts: 6
Stumble this Post!
Fantastic. That works a treat. I've not thought about using Perl before. Perhaps it's time I took a look at it!

Thanks for your help.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:16 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0