The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Replacing a character string in a file rjsha1 Shell Programming and Scripting 13 04-11-2009 01:07 PM
Replacing a string in nth line maxmave Shell Programming and Scripting 1 06-04-2008 05:32 PM
string replacing priya_9patil Shell Programming and Scripting 1 11-03-2006 12:05 PM
replacing a string in a file with command line parameter chiru_h Shell Programming and Scripting 5 08-03-2006 09:34 AM
Help needed - Replacing all date & time occurrences in a file with a string using Sed Hema_M Shell Programming and Scripting 4 11-17-2005 01:42 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-03-2008
subin_bala subin_bala is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 57
replacing string in an XML file

Hi all,

I need to replace string in XML file..XML file like
<dependency>
<groupId>fr.orange.portail.ear</groupId>
<artifactId>_AdminServicesEAR</artifactId>
<version>1.0.0-20080521.085352-1</version>
<type>ear</type>
</dependency>
<dependency>
<groupId>fr.orange.portail.ear</groupId>
<artifactId>_AdminServicesEAR</artifactId>
<version>1.0.0-20080521.085352-1</version>
<type>ear</type>
</dependency>


I need to replace the value between <type> </type> tag at first occurance. i am using following sed command now but it is replacing the tag value globally

sed 's#<type>\([^<][^<]*\)</type>#<type>newvalue</type>#' application.xml > application.xml.new



Can anyone gelp me ....

Thanks and Regards,
  #2 (permalink)  
Old 06-03-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,915
By default sed operates on every line of a file. Your command line argument is telling sed to replace the first instance of <type>\([^<][^<]*\)</type> with <type>newvalue</type> in each line of the file.
  #3 (permalink)  
Old 06-03-2008
subin_bala subin_bala is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 57
Thnks for the reply ...
So is it possible for me to replace only the first occurance of <type> </type> value by using any other sed command ?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:42 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0