Results 1 to 6 of 6

Thread: SED with quotes

  1. #1
    Join Date
    Nov 2009
    Posts
    518

    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.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    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.

  3. #3
    Join Date
    Nov 2009
    Posts
    518

    Re: SED with quotes

    Hi,
    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
    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.

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    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.

  5. #5
    Join Date
    Nov 2009
    Posts
    518

    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.

  6. #6
    Join Date
    May 2008
    Posts
    2,297

    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.

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,367,931.00828 seconds with 16 queries