<?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 Re: Using SED with backslashes in string in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-with-backslashes-in-string/m-p/4688921#M658928</link>
    <description>&amp;gt;Viktor: You shouldn't use the slash as the separator character in sed.&lt;BR /&gt;&lt;BR /&gt;Well in this case, "/" wasn't being used.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;But in this case you need to escape the characters because \name1 would be meant&lt;BR /&gt;&lt;BR /&gt;You almost always need to escape "\" if you want a backslash.  It doesn't matter if there was a "n".&lt;BR /&gt;Since it is in '', the shell doesn't see it but sed(1) has its own rules about "\".</description>
    <pubDate>Tue, 21 Sep 2010 21:56:46 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2010-09-21T21:56:46Z</dc:date>
    <item>
      <title>Using SED with backslashes in string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-with-backslashes-in-string/m-p/4688915#M658922</link>
      <description>Hello,&lt;BR /&gt;I need to search a file for a computer name and replace it with a DFS path, for instance, search for all instances of &lt;BR /&gt;&lt;BR /&gt;caetwk-srv3&lt;BR /&gt;&lt;BR /&gt;and replace with&lt;BR /&gt;&lt;BR /&gt;\\us\name1\name2\name3&lt;BR /&gt;&lt;BR /&gt;How would this replace command look in sed??&lt;BR /&gt;Thanks in advance!</description>
      <pubDate>Mon, 20 Sep 2010 14:12:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-with-backslashes-in-string/m-p/4688915#M658922</guid>
      <dc:creator>Theresa Patrie</dc:creator>
      <dc:date>2010-09-20T14:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using SED with backslashes in string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-with-backslashes-in-string/m-p/4688916#M658923</link>
      <description>Hi Theresa:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; How would this replace command look in sed??&lt;BR /&gt;&lt;BR /&gt;Very ugly, like this:&lt;BR /&gt;&lt;BR /&gt;# echo "caetwk-srv3"|sed -e s/caetwk-srv3/\\\\\\\\us\\\\name1\\\\name2\\\\name3/&lt;BR /&gt;\\us\name1\name2\name3&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 20 Sep 2010 14:19:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-with-backslashes-in-string/m-p/4688916#M658923</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-09-20T14:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using SED with backslashes in string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-with-backslashes-in-string/m-p/4688917#M658924</link>
      <description>Hi (again) Theresa:&lt;BR /&gt;&lt;BR /&gt;If you use Perl, you can greatly improve the readability and easily perform the desired substitution:&lt;BR /&gt;&lt;BR /&gt;# echo "caetwk-srv3"|perl -pe 's{caetwk-srv3}{\\\\us\\name1\\name2\\name3}'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 20 Sep 2010 15:34:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-with-backslashes-in-string/m-p/4688917#M658924</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-09-20T15:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using SED with backslashes in string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-with-backslashes-in-string/m-p/4688918#M658925</link>
      <description>Wow, thanks James for the quick response.  So many backslashes!!!&lt;BR /&gt;&lt;BR /&gt;My command looks like this and works fine&lt;BR /&gt;&lt;BR /&gt;sed -e s/caetwk-srv3/us\\\name1\\\name2\\\name3/g inputfile &amp;gt;outputfile&lt;BR /&gt;&lt;BR /&gt;Thank you very much!&lt;BR /&gt;&lt;BR /&gt;P.S. There was already a double-backslash in front of caetwk-srv3, so I just left that alone and didn't have to insert any before "us"</description>
      <pubDate>Mon, 20 Sep 2010 16:24:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-with-backslashes-in-string/m-p/4688918#M658925</guid>
      <dc:creator>Theresa Patrie</dc:creator>
      <dc:date>2010-09-20T16:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using SED with backslashes in string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-with-backslashes-in-string/m-p/4688919#M658926</link>
      <description>Hi Theresa:&lt;BR /&gt;&lt;BR /&gt;NO POINTS FOR THIS, but I should have escaped the 'sed' program as:&lt;BR /&gt;&lt;BR /&gt;# echo "caetwk-srv3"|sed -e 's/caetwk-srv3/\\\\us\\name1\\name2\\name3/'&lt;BR /&gt;&lt;BR /&gt;Doing so would have negated the need for doubling the backslashes as I first did!&lt;BR /&gt;&lt;BR /&gt;NO POINTS FOR THIS.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 20 Sep 2010 16:53:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-with-backslashes-in-string/m-p/4688919#M658926</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-09-20T16:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using SED with backslashes in string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-with-backslashes-in-string/m-p/4688920#M658927</link>
      <description>You shouldn't use the slash as the separator character in sed. It can be some other character like . , ; #&lt;BR /&gt;&lt;BR /&gt;But in this case you need to escape the characters because \name1 would be meant as a newline character with the string "ame1".&lt;BR /&gt;&lt;BR /&gt;To clarify it, these also work:&lt;BR /&gt;&lt;BR /&gt;# echo test | sed 's.test.TEST.'&lt;BR /&gt;TEST&lt;BR /&gt;&lt;BR /&gt;and&lt;BR /&gt;&lt;BR /&gt;# echo test | sed 's#test#TEST#'&lt;BR /&gt;TEST&lt;BR /&gt;&lt;BR /&gt;But, as I said, in this case the special meaning of \n causes you another problem:&lt;BR /&gt;&lt;BR /&gt;# echo caetwk-srv3 | sed 's.caetwk-srv3.\\us\name1\name2\name3.'&lt;BR /&gt;\us&lt;BR /&gt;ame1&lt;BR /&gt;ame2&lt;BR /&gt;ame3&lt;BR /&gt;#</description>
      <pubDate>Tue, 21 Sep 2010 15:37:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-with-backslashes-in-string/m-p/4688920#M658927</guid>
      <dc:creator>Viktor Balogh</dc:creator>
      <dc:date>2010-09-21T15:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: Using SED with backslashes in string</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-with-backslashes-in-string/m-p/4688921#M658928</link>
      <description>&amp;gt;Viktor: You shouldn't use the slash as the separator character in sed.&lt;BR /&gt;&lt;BR /&gt;Well in this case, "/" wasn't being used.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;But in this case you need to escape the characters because \name1 would be meant&lt;BR /&gt;&lt;BR /&gt;You almost always need to escape "\" if you want a backslash.  It doesn't matter if there was a "n".&lt;BR /&gt;Since it is in '', the shell doesn't see it but sed(1) has its own rules about "\".</description>
      <pubDate>Tue, 21 Sep 2010 21:56:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-with-backslashes-in-string/m-p/4688921#M658928</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-09-21T21:56:46Z</dc:date>
    </item>
  </channel>
</rss>

