Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , , ,

Sponsored Links



SED with quotes

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 25-12-2009
Member
 
Join Date: Nov 2009
Posts: 520
SED with quotes

Hello,
I would like to replace a file option. This option is as follows:
Code:
OPTION = "TRUE"
With SED I would take the option to FALSE so I starting like this:
Code:
sed-i-e 's / OPTION = "TRUE" / OPTION = "FALSE" / g' / etc / file
This does not work. How can I make this work with the sed command? Help needed guys! Thank you in advance.
Reply With Quote
  #2  
Old 25-12-2009
Member
 
Join Date: May 2008
Posts: 1,990
Re: SED with quotes

Hi
Code:
sed-i-e 's / OPTION = "TRUE" / OPTION = "FALSE" / g' / etc / file
Instead of this ou can use character escaping "\"
Code:
sed 's / OPTION = \ "true \" / OPTION = \ "false \" / g'
Try this and see if it works, other wise we have lots of options to do that.
Reply With Quote
  #3  
Old 25-12-2009
Member
 
Join Date: Nov 2009
Posts: 520
Re: SED with quotes

Hi,
Quote:
sed 's / OPTION = \ "true \" / OPTION = \ "false \" / g'
I tried the above command in the terminal with sed, but sorry, it does not work anyway I tried, I get an error message like
Quote:
sed:-e expression nA 1, characterized " re 45: unknown option to `s'
Any more commands or options of sed you know? Or is there any other way to achieve the same.
Reply With Quote
  #4  
Old 25-12-2009
Member
 
Join Date: May 2008
Posts: 1,990
Re: SED with quotes

Hi
Well we may not be quite using the same version of sed, But for information I just create a file with contents test.txt
Code:
OPTION = "TRUE"
and control this way
Code:
sed-i-e 's / OPTION = \ "true \" / OPTION = \ "false \" / g' test.txt
Follow the same procedure and you will get the results.
Reply With Quote
  #5  
Old 25-12-2009
Member
 
Join Date: Nov 2009
Posts: 520
Re: SED with quotes

Hello
On a simple option that works:
Code:
OPTION = "TRUE"
But by cons on an option "view" this does not:
Code:
OPTION = "-u user-p password"
If I change the option as
Code:
OPTION = "-u test-p tty"
I use sed in a debian lenny, not sure about the version of sed, but I have not updated the version, it is the default version which comes with debian lenny.
Reply With Quote
  #6  
Old 25-12-2009
Zecho's Avatar
Member
 
Join Date: May 2008
Posts: 2,267
Re: SED with quotes

Hello,
Sed uses the delimiter called slash. For sed that does not confuse them with slashes of chemisn delimiter, it must be protected in the same manner as other special characters.
Code:
sed-i-e 's / = OPTION \ "-u test-p password-h \ / var \ / lib \ / test \" / OPTION = \
Hope you get the point, these are the basic of sed and off-course linux.
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "SED with quotes"
Thread Thread Starter Forum Replies Last Post
Best Video Game quotes Weslee Video Games 9 03-01-2012 10:29 PM
Need help with Morningstar Quotes for Firefox 5 Merka Technology & Internet 5 27-06-2011 11:28 PM
What are Magic Quotes in PHP? Rob Dizzle Software Development 5 05-03-2010 12:33 AM
Regex string with quotes Gunner 1 Software Development 5 07-02-2010 06:03 AM
How to embed quotes in t-sql joel84 Software Development 3 03-08-2009 04:01 PM


All times are GMT +5.5. The time now is 12:12 PM.