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 nulls using sed novice1324 Shell Programming and Scripting 7 02-27-2008 03:56 AM
help in replacing ?? zedex Shell Programming and Scripting 5 08-31-2007 01:45 AM
replacing corrupt /tmp dir.. moxxx68 UNIX for Advanced & Expert Users 6 05-28-2005 06:58 PM
replacing with `pwd` oldtrash Shell Programming and Scripting 6 04-09-2004 06:24 PM
replacing \n by \r\n crashnburn UNIX for Dummies Questions & Answers 3 11-24-2003 03:49 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-05-2006
superprogrammer superprogrammer is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 26
Replacing in SED

I want to change the false in Node 1 to true. How do I do that?
<Node1>
<Usage>false</Usage>
<Url>ABC</Url>
</Node1>

<Node2>
<Usage>false</Usage>
<Url>DEF<Url>
</Node2>
  #2 (permalink)  
Old 07-05-2006
nir_s nir_s is offline
Registered User
  
 

Join Date: Jun 2004
Posts: 148
Try:
Code:
/tmp # echo "
> <Node1>
> <Usage>false</Usage>
> <Url>ABC</Url>
> </Node1>
>         
> <Node2>
> <Usage>false</Usage>
> <Url>DEF<Url>
> </Node2>" | sed -e 's/false/true/g'

<Node1>
<Usage>true</Usage>
<Url>ABC</Url>
</Node1>

<Node2>
<Usage>true</Usage>
<Url>DEF<Url>
</Node2>
or:

Code:
sed -e 's/false/true/g' file > file.new
Regards,
Nir
  #3 (permalink)  
Old 07-05-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Code:
sed -e "/<Node1>/,/<\/Node1>/{s_<Usage>false</Usage>_<Usage>true</Usage>_}" file.old > file.new
  #4 (permalink)  
Old 07-05-2006
superprogrammer superprogrammer is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 26
I am getting command garbled
  #5 (permalink)  
Old 07-05-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Code:
sed 's#<Usage>false#<Usage>true#g' myFile
  #6 (permalink)  
Old 07-06-2006
superprogrammer superprogrammer is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 26
Thanks but it converts both the values to true

Remember, I just want to change the value in Node1
  #7 (permalink)  
Old 07-06-2006
grial's Avatar
grial grial is offline Forum Advisor  
El UNIX es como un toro
  
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
Vino's solution does what you want.
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 04:27 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