<?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: Sed Command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-command/m-p/4403463#M351952</link>
    <description>&lt;!--!*#--&gt;&amp;gt; What does the below command retuens?&lt;BR /&gt;&lt;BR /&gt;"Life is like a sewer.  What you get out of&lt;BR /&gt;it depends on what you put into it."&lt;BR /&gt;&lt;BR /&gt;dyi # echo "a'b c'd" | sed "s/'/\\\\\'/g" | sed 's/ /\\\\ /g'&lt;BR /&gt;a\'b\\ c\'d&lt;BR /&gt;&lt;BR /&gt;Note, however, that:&lt;BR /&gt;&lt;BR /&gt;dyi # echo "a'b c'd" | sed "s/'/\\\'/g" | sed 's/ /\\\\ /g'&lt;BR /&gt;a\'b\\ c\'d&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Please explain with example.&lt;BR /&gt;&lt;BR /&gt;Please supply some context.  Is there some&lt;BR /&gt;actual problem which you are trying to solve?</description>
    <pubDate>Sat, 18 Apr 2009 10:50:58 GMT</pubDate>
    <dc:creator>Steven Schweda</dc:creator>
    <dc:date>2009-04-18T10:50:58Z</dc:date>
    <item>
      <title>Sed Command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-command/m-p/4403462#M351951</link>
      <description>What does the below command retuens?&lt;BR /&gt;&lt;BR /&gt;temp=`echo "$1" | sed "s/'/\\\\\'/g" | sed 's/ /\\\\ /g'`&lt;BR /&gt;&lt;BR /&gt;Please explain with example. Thanks a lot.&lt;BR /&gt;&lt;BR /&gt;Siva</description>
      <pubDate>Sat, 18 Apr 2009 09:39:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-command/m-p/4403462#M351951</guid>
      <dc:creator>Sivasubramanian S</dc:creator>
      <dc:date>2009-04-18T09:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: Sed Command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-command/m-p/4403463#M351952</link>
      <description>&lt;!--!*#--&gt;&amp;gt; What does the below command retuens?&lt;BR /&gt;&lt;BR /&gt;"Life is like a sewer.  What you get out of&lt;BR /&gt;it depends on what you put into it."&lt;BR /&gt;&lt;BR /&gt;dyi # echo "a'b c'd" | sed "s/'/\\\\\'/g" | sed 's/ /\\\\ /g'&lt;BR /&gt;a\'b\\ c\'d&lt;BR /&gt;&lt;BR /&gt;Note, however, that:&lt;BR /&gt;&lt;BR /&gt;dyi # echo "a'b c'd" | sed "s/'/\\\'/g" | sed 's/ /\\\\ /g'&lt;BR /&gt;a\'b\\ c\'d&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Please explain with example.&lt;BR /&gt;&lt;BR /&gt;Please supply some context.  Is there some&lt;BR /&gt;actual problem which you are trying to solve?</description>
      <pubDate>Sat, 18 Apr 2009 10:50:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-command/m-p/4403463#M351952</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-04-18T10:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: Sed Command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-command/m-p/4403464#M351953</link>
      <description>It seems for every blank it adds a "\" before them.  And for every "'" it adds two "\\" before them.&lt;BR /&gt;&lt;BR /&gt;And when this pipeline is wrapped in $(), that double backslash is converted into just one.&lt;BR /&gt;$  script.sh "xx'yy zz"&lt;BR /&gt;xx\'yy\ zz&lt;BR /&gt;xx\'yy\\ zz  # with just echo&lt;BR /&gt;&lt;BR /&gt;Hmm, it appears sed gets different number of backslashes depending on whether $() or ``.&lt;BR /&gt;But it seems the output is the same:&lt;BR /&gt;$():&lt;BR /&gt;argv[0]: "sed"&lt;BR /&gt;argv[1]: "-e"&lt;BR /&gt;argv[2]: "s/'/\\\'/g"&lt;BR /&gt;argv[3]: "-e"&lt;BR /&gt;argv[4]: "s/ /\\\\ /g"&lt;BR /&gt;&lt;BR /&gt;``:&lt;BR /&gt;argv[0]: "sed"&lt;BR /&gt;argv[1]: "-e"&lt;BR /&gt;argv[2]: "s/'/\\'/g"&lt;BR /&gt;argv[3]: "-e"&lt;BR /&gt;argv[4]: "s/ /\\ /g"&lt;BR /&gt;&lt;BR /&gt;Neither:&lt;BR /&gt;argv[0]: "sed"&lt;BR /&gt;argv[1]: "-e"&lt;BR /&gt;argv[2]: "s/'/\\\'/g"&lt;BR /&gt;argv[3]: "-e"&lt;BR /&gt;argv[4]: "s/ /\\\\ /g"&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Please explain with example&lt;BR /&gt;&lt;BR /&gt;So basically this (how many backslashes you need) can't be explained very well.  :-(</description>
      <pubDate>Sat, 18 Apr 2009 11:39:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-command/m-p/4403464#M351953</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-04-18T11:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: Sed Command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-command/m-p/4403465#M351954</link>
      <description>Thanks Dennis. &lt;BR /&gt;&lt;BR /&gt;P.S Since this was part of a  generic script, the purpose of which could not be understood, I had to frame such a generic question.&lt;BR /&gt;&lt;BR /&gt;Siva</description>
      <pubDate>Mon, 20 Apr 2009 19:04:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-command/m-p/4403465#M351954</guid>
      <dc:creator>Sivasubramanian S</dc:creator>
      <dc:date>2009-04-20T19:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: Sed Command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-command/m-p/4403466#M351955</link>
      <description>the snippet posted *might* be of use when the contents of "temp" is echoed to a file, and the contents of the file is subsequently read into a shell variable. In that case, the spaces and single-qoutes are retained (although double-qoutes are a different matter)</description>
      <pubDate>Mon, 20 Apr 2009 19:55:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-command/m-p/4403466#M351955</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-04-20T19:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Sed Command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-command/m-p/4403467#M351956</link>
      <description>Here is the output of the command.&lt;BR /&gt;&lt;BR /&gt;/home/test&amp;gt;cat file1&lt;BR /&gt;123&lt;BR /&gt;'123'&lt;BR /&gt;' 123 '&lt;BR /&gt;' 123'&lt;BR /&gt;'123&lt;BR /&gt;' 123&lt;BR /&gt;&lt;BR /&gt;/home/test&amp;gt;sed "s/'/\\\\\'/g" file1&lt;BR /&gt;                  &lt;BR /&gt;123&lt;BR /&gt;\'123\'&lt;BR /&gt;\' 123 \'&lt;BR /&gt;\' 123\'&lt;BR /&gt;\'123&lt;BR /&gt;\' 123&lt;BR /&gt;&lt;BR /&gt;/home/test&amp;gt;sed "s/'/\\\\\'/g" file1|sed 's/ /\\\\ /g'&lt;BR /&gt;&lt;BR /&gt;123&lt;BR /&gt;\'123\'&lt;BR /&gt;\'\\ 123\\ \'&lt;BR /&gt;\'\\ 123\'&lt;BR /&gt;\'123&lt;BR /&gt;\'\\ 123&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Not sure of the choice of the number of back slashes.&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Apr 2009 21:11:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-command/m-p/4403467#M351956</guid>
      <dc:creator>Sivasubramanian S</dc:creator>
      <dc:date>2009-04-20T21:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: Sed Command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-command/m-p/4403468#M351957</link>
      <description>&lt;!--!*#--&gt;This appears to be an example of what it *could* be used for:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;fsm.sh&lt;BR /&gt;====================================================&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;temp=`echo "$1" | sed "s/'/\\\\\'/g" | sed 's/ /\\\\ /g'`&lt;BR /&gt;echo $temp&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;fsm1.sh&lt;BR /&gt;====================================================&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;read temp2&lt;BR /&gt;echo $temp2&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;sample use:&lt;BR /&gt;===================================================&lt;BR /&gt;&lt;BR /&gt;A:&lt;BR /&gt;&lt;BR /&gt; ./fsm.sh "12 db ' '   456" &amp;gt; oo.out&lt;BR /&gt; ./fsm1.sh &amp;lt; oo.out&lt;BR /&gt; 12 db ' ' 456&lt;BR /&gt;&lt;BR /&gt;B:&lt;BR /&gt; ./fsm.sh "12 db ' '   456" | ./fsm1.sh&lt;BR /&gt; 12 db ' ' 456&lt;BR /&gt;&lt;BR /&gt;As noted previously, its used to maintain qoutes and spacing....</description>
      <pubDate>Tue, 21 Apr 2009 12:33:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-command/m-p/4403468#M351957</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2009-04-21T12:33:18Z</dc:date>
    </item>
  </channel>
</rss>

