<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Backslash in SED in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/backslash-in-sed/m-p/2480532#M776768</link>
    <description>I am trying to use SED to alter a variable with forward slashes in it (an omniback session reference "2000/12/31-5"). The aim is to use this variable in another SED statement to subtitute it for another String, but the forward slahes cause problems. I was intending to program in backslashes before each forward slash in the variable, then use the result to replace the relevant strings.&lt;BR /&gt;&lt;BR /&gt;Command 1 = export $SESSION = echo 2000/12/31-5 | sed -e "s/\//\/g" # (Replace / with \/ - doesn't work)&lt;BR /&gt;&lt;BR /&gt;Command 2 = sed -e "s/var1/$SESSION/g"        # ($SESSION = result of Command1)&lt;BR /&gt;&lt;BR /&gt;Any ideas?</description>
    <pubDate>Mon, 08 Jan 2001 20:40:14 GMT</pubDate>
    <dc:creator>FRED Dennison</dc:creator>
    <dc:date>2001-01-08T20:40:14Z</dc:date>
    <item>
      <title>Backslash in SED</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/backslash-in-sed/m-p/2480532#M776768</link>
      <description>I am trying to use SED to alter a variable with forward slashes in it (an omniback session reference "2000/12/31-5"). The aim is to use this variable in another SED statement to subtitute it for another String, but the forward slahes cause problems. I was intending to program in backslashes before each forward slash in the variable, then use the result to replace the relevant strings.&lt;BR /&gt;&lt;BR /&gt;Command 1 = export $SESSION = echo 2000/12/31-5 | sed -e "s/\//\/g" # (Replace / with \/ - doesn't work)&lt;BR /&gt;&lt;BR /&gt;Command 2 = sed -e "s/var1/$SESSION/g"        # ($SESSION = result of Command1)&lt;BR /&gt;&lt;BR /&gt;Any ideas?</description>
      <pubDate>Mon, 08 Jan 2001 20:40:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/backslash-in-sed/m-p/2480532#M776768</guid>
      <dc:creator>FRED Dennison</dc:creator>
      <dc:date>2001-01-08T20:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: Backslash in SED</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/backslash-in-sed/m-p/2480533#M776769</link>
      <description>it should be :&lt;BR /&gt;sed -e 's/\//\\\/g'&lt;BR /&gt;&lt;BR /&gt;or you can use another delimiter:&lt;BR /&gt;&lt;BR /&gt;sed -d 's|/|\\/|g'&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Jan 2001 20:53:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/backslash-in-sed/m-p/2480533#M776769</guid>
      <dc:creator>Curtis Larson</dc:creator>
      <dc:date>2001-01-08T20:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Backslash in SED</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/backslash-in-sed/m-p/2480534#M776770</link>
      <description>oops that should have been a -e instead of -d:&lt;BR /&gt;&lt;BR /&gt;and, of course, if you use a different delimiter you don't need to backslash your slashes in the substitution</description>
      <pubDate>Mon, 08 Jan 2001 20:56:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/backslash-in-sed/m-p/2480534#M776770</guid>
      <dc:creator>Curtis Larson</dc:creator>
      <dc:date>2001-01-08T20:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: Backslash in SED</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/backslash-in-sed/m-p/2480535#M776771</link>
      <description>Fred:&lt;BR /&gt;&lt;BR /&gt;Try:&lt;BR /&gt;&lt;BR /&gt;# echo 2000/12/31-5 | sed -e "s?/?\\\?g"&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Jan 2001 20:57:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/backslash-in-sed/m-p/2480535#M776771</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-01-08T20:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Backslash in SED</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/backslash-in-sed/m-p/2480536#M776772</link>
      <description>Thanks for your assistance. It's works OK now.&lt;BR /&gt;&lt;BR /&gt;Interesting point; the answers above gives the result I wanted to stdout, but to store it in a variable, I had to put another 3 \ characters in the sed command. End result was&lt;BR /&gt;&lt;BR /&gt;export S2='echo $S1|sed -e "s?/?\\\\\\\/?g"'&lt;BR /&gt;&lt;BR /&gt;with ? as delimeter.&lt;BR /&gt;&lt;BR /&gt;FRED</description>
      <pubDate>Mon, 08 Jan 2001 23:53:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/backslash-in-sed/m-p/2480536#M776772</guid>
      <dc:creator>FRED Dennison</dc:creator>
      <dc:date>2001-01-08T23:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: Backslash in SED</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/backslash-in-sed/m-p/2480537#M776773</link>
      <description>Hi Fred,&lt;BR /&gt;&lt;BR /&gt;The reason why you have to add a couple backslashes when assigning the result to a variable is the following:&lt;BR /&gt;Using double quotes doesn't prevent your shell from interpreting the string, you should use simple quotes instead, like in:&lt;BR /&gt;a=`echo 2000/12/31-5 | sed -e 's#/#\\\#g'`&lt;BR /&gt;&lt;BR /&gt;This keeps the whole expression 'more readable'.  ;-)&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;BR /&gt;Dan</description>
      <pubDate>Tue, 09 Jan 2001 10:41:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/backslash-in-sed/m-p/2480537#M776773</guid>
      <dc:creator>Dan Hetzel</dc:creator>
      <dc:date>2001-01-09T10:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Backslash in SED</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/backslash-in-sed/m-p/2480538#M776774</link>
      <description>sed uses ed and that states that "s/whatever/something/" can be "s;whatever;something;". IE the "/" is an ed delimiter. Using anything other than "/" usually gets rid of the problems you are having.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;ian</description>
      <pubDate>Tue, 09 Jan 2001 15:55:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/backslash-in-sed/m-p/2480538#M776774</guid>
      <dc:creator>Ian_9</dc:creator>
      <dc:date>2001-01-09T15:55:01Z</dc:date>
    </item>
  </channel>
</rss>

