Find the answer to your Linux question:
Results 1 to 3 of 3
Hi everyone, I'm using sed to edit some text, and I have this code in a section. In this example I'm trying to replace some html code with a single ...
  1. #1
    Just Joined!
    Join Date
    Jan 2009
    Location
    Halifax, NS
    Posts
    19

    Cancel character not working in this case

    Hi everyone,

    I'm using sed to edit some text, and I have this code in a section.
    In this example I'm trying to replace some html code with a single quote character.
    Thus, &rsquo => '

    Code:
    sed 's/’/\'/g'
    It doesn't cancel the rightside quote, and thus gives me an error.
    This code is part of a longer line, so multiple sed operations on the same line. So I tried leaving out the single quotes at the beginning and end of the operations, but also returned an error.

  2. #2
    Just Joined!
    Join Date
    Jan 2009
    Location
    Halifax, NS
    Posts
    19
    Also, I can't do

    Code:
    sed "s/’/'/g"
    because I'm replacing the double quotes further on on the same line as well.

    So more specifically, I need it to work for this

    Code:
    sed 's/’/'/g; s/”/"/g; s/“/"/g'
    It replaces the double quotes fine though.

    To make it more understandable, rsquo = right side single quote, rdquo = right side double quote, and ldquo = left side double quote.

  3. #3
    Just Joined!
    Join Date
    Jan 2009
    Location
    Halifax, NS
    Posts
    19
    I decided to work around it.

    Instead of grouping all the sed commands like that, I used the -e option to group them, and then used the double quotes for the sed command that replaces the single quote.

    Problem fixed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...