<?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: help with SED in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016472#M718796</link>
    <description>Hello!&lt;BR /&gt;&lt;BR /&gt;In sed you use "/" and not "|"&lt;BR /&gt;do this:&lt;BR /&gt;sed "s/${EXPORIG}/${NEWEXP}/g" &lt;FILE&gt; &lt;BR /&gt;&lt;BR /&gt;Caesar&lt;/FILE&gt;</description>
    <pubDate>Mon, 07 Jul 2003 19:29:18 GMT</pubDate>
    <dc:creator>Caesar_3</dc:creator>
    <dc:date>2003-07-07T19:29:18Z</dc:date>
    <item>
      <title>help with SED</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016465#M718789</link>
      <description>Hello,&lt;BR /&gt;here my script :&lt;BR /&gt;##&lt;BR /&gt;EXPORIG=toto&lt;BR /&gt;NEWEXP=bibi&lt;BR /&gt;sed -e 's|"$EXPORIG"|"$NEWEXP"|g' file&lt;BR /&gt;##&lt;BR /&gt;the syntax in sed command is not correct&lt;BR /&gt;i want to replace "$EXPORIG" with "$NEWEXP"&lt;BR /&gt;in "file"&lt;BR /&gt;how to insert a variable in sed command ?&lt;BR /&gt;Thank's</description>
      <pubDate>Mon, 07 Jul 2003 08:00:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016465#M718789</guid>
      <dc:creator>iranzo</dc:creator>
      <dc:date>2003-07-07T08:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: help with SED</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016466#M718790</link>
      <description>I am assuming that you do not want to retain the " (double quote) symbols?&lt;BR /&gt;&lt;BR /&gt;sed "s/$EXPORIG/$NEWEXP/g" file&lt;BR /&gt;&lt;BR /&gt;tested with a pipe command for the file, but still tested!&lt;BR /&gt;&lt;BR /&gt;Share and Enjoy! Ian</description>
      <pubDate>Mon, 07 Jul 2003 08:04:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016466#M718790</guid>
      <dc:creator>Ian Dennison_1</dc:creator>
      <dc:date>2003-07-07T08:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: help with SED</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016467#M718791</link>
      <description>Hi,&lt;BR /&gt;Ian gave you an answer.&lt;BR /&gt;&lt;BR /&gt;I think that your command was not working because the | was mis-interpreted by the shell.&lt;BR /&gt;&lt;BR /&gt;Simply choosing a different separator will do the trick.&lt;BR /&gt;&lt;BR /&gt;   Massimo&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Jul 2003 08:48:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016467#M718791</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2003-07-07T08:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: help with SED</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016468#M718792</link>
      <description>I have noticed a problem with putting variables into sed statements before as well.  if Ian's statement above doesn't work you could try this as a last result&lt;BR /&gt;&lt;BR /&gt;EXPORIG=toto&lt;BR /&gt;NEWEXP=bibi&lt;BR /&gt;echo sed \'s/$EXPORIG/$NEWEXP/g\' file &amp;gt; replace.sh&lt;BR /&gt;chmod +x replace.sh&lt;BR /&gt;./replace.sh&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Jul 2003 10:15:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016468#M718792</guid>
      <dc:creator>John Meissner</dc:creator>
      <dc:date>2003-07-07T10:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: help with SED</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016469#M718793</link>
      <description>Hi,&lt;BR /&gt;whith sed you have need to redirect the output in a new file to save the change.&lt;BR /&gt;A friend tell me to try this for change and save in the same file,and its works.&lt;BR /&gt;&lt;BR /&gt;Maybe is a good idea to make a back_up of file befour before!!!!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ed - file &amp;lt;&amp;lt; EOF&lt;BR /&gt;1,$ s/$EXPORIG/$NEWEXP/g&lt;BR /&gt;w file&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Sorry for my english ;)&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Jul 2003 11:51:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016469#M718793</guid>
      <dc:creator>flavia</dc:creator>
      <dc:date>2003-07-07T11:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: help with SED</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016470#M718794</link>
      <description>Replace this:&lt;BR /&gt;sed -e 's|"$EXPORIG"|"$NEWEXP"|g' file &lt;BR /&gt;&lt;BR /&gt;With this:&lt;BR /&gt;&lt;BR /&gt;eval sed 's/$EXPORIG/$NEWEXP/g' file&lt;BR /&gt;&lt;BR /&gt;Hai&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Jul 2003 12:13:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016470#M718794</guid>
      <dc:creator>Hai Nguyen_1</dc:creator>
      <dc:date>2003-07-07T12:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: help with SED</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016471#M718795</link>
      <description>The issue here is quoting of special characters such as | and " in combination with not quoting shell variables such as $EXPORIG.&lt;BR /&gt;&lt;BR /&gt;  Ian's solution will handle most cases where you did not really want the "'s to appear in the pattern you replace-&lt;BR /&gt;sed "s/$EXPORIG/$NEWEXP/g" file&lt;BR /&gt;The double quotes will quote the special characters but allow the variables to be expanded.&lt;BR /&gt;&lt;BR /&gt;  His solution will have trouble if there are any / symbols in the variables.  Using | for the sed substitution will handle / characters in the pattern, but won't handle | characters in the pattern.  To handle all strings in the patterns you will need to actively quote the character that you are using to delimit the patterns.  Here is an example that uses / characters as the delimiter.  The first two sed commands add quoting backslash characters as needed.&lt;BR /&gt;QUOTEDEXPORIG="$(print $EXPORIG | sed -e 's|/|\\/|g')"&lt;BR /&gt;QUOTEDNEWEXP="$(print $NEWEXP | sed -e 's|/|\\/|g')"&lt;BR /&gt;sed -e "s/$QUOTEDEXPORIG/$QUOTEDNEWEXP/g" file&lt;BR /&gt;&lt;BR /&gt;  You might want to quote other wildcard characters as well.  Here is an example that quotes every special character.  It can handle characters like . and * in the patterns.&lt;BR /&gt;QUOTEDEXPORIG="$(print $EXPORIG | sed -e 's|[/.[\*^]|\\&amp;amp;|g')"&lt;BR /&gt;QUOTEDNEWEXP="$(print $NEWEXP | sed -e 's|[/.[\*^]|\\&amp;amp;|g')"&lt;BR /&gt;sed -e "s/$QUOTEDEXPORIG/$QUOTEDNEWEXP/g" file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Jul 2003 18:16:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016471#M718795</guid>
      <dc:creator>Mike Stroyan</dc:creator>
      <dc:date>2003-07-07T18:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: help with SED</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016472#M718796</link>
      <description>Hello!&lt;BR /&gt;&lt;BR /&gt;In sed you use "/" and not "|"&lt;BR /&gt;do this:&lt;BR /&gt;sed "s/${EXPORIG}/${NEWEXP}/g" &lt;FILE&gt; &lt;BR /&gt;&lt;BR /&gt;Caesar&lt;/FILE&gt;</description>
      <pubDate>Mon, 07 Jul 2003 19:29:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016472#M718796</guid>
      <dc:creator>Caesar_3</dc:creator>
      <dc:date>2003-07-07T19:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: help with SED</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016473#M718797</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;As a point of clarification (and I quote from the 'sed' man pages since it says it so well!)"&lt;BR /&gt;&lt;BR /&gt;"An address is either a decimal number that counts input lines cumulatively across files, a $ which addresses the last line of input,&lt;BR /&gt;or a context address; that is, a /regular expression/...  In a context address, the construction \?regular expression?, where ? is any character, is identical to /regular expression/."&lt;BR /&gt;&lt;BR /&gt;For substitutions, "s/regular expression/replacement/flags: Substitute replacement string for instances of regular xpression in the pattern space.  Any character can be used instead of /."&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 07 Jul 2003 23:52:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-sed/m-p/3016473#M718797</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-07-07T23:52:06Z</dc:date>
    </item>
  </channel>
</rss>

