<?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: Replace string in file in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-string-in-file/m-p/4251866#M331688</link>
    <description>You can use sed(1):&lt;BR /&gt;a=/abc/efg&lt;BR /&gt;b=/qwerty&lt;BR /&gt;sed -e "s:\\($a$b\\):#\\1:" test &amp;gt; test.new</description>
    <pubDate>Thu, 14 Aug 2008 06:46:08 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2008-08-14T06:46:08Z</dc:date>
    <item>
      <title>Replace string in file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-string-in-file/m-p/4251864#M331686</link>
      <description>Hi,&lt;BR /&gt;My file "test" contains /abc/efg/qwerty&lt;BR /&gt;&lt;BR /&gt;and my variables a and b contains&lt;BR /&gt;a=/abc/efg&lt;BR /&gt;b=/qwerty&lt;BR /&gt;how can i repace the contents of my file &lt;BR /&gt;"testt" with #/abc/efg/qwerty using a and b variables</description>
      <pubDate>Thu, 14 Aug 2008 05:57:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-string-in-file/m-p/4251864#M331686</guid>
      <dc:creator>chandregowda</dc:creator>
      <dc:date>2008-08-14T05:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Replace string in file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-string-in-file/m-p/4251865#M331687</link>
      <description>Shalom&lt;BR /&gt;&lt;BR /&gt;sed is a good tool&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.linuxquestions.org/questions/linux-newbie-8/does-anyone-know-of-a-bash-script-can-search-and-replace-txt-in-a-file.-278332/" target="_blank"&gt;http://www.linuxquestions.org/questions/linux-newbie-8/does-anyone-know-of-a-bash-script-can-search-and-replace-txt-in-a-file.-278332/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=57865" target="_blank"&gt;http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=57865&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Thu, 14 Aug 2008 06:44:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-string-in-file/m-p/4251865#M331687</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2008-08-14T06:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: Replace string in file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-string-in-file/m-p/4251866#M331688</link>
      <description>You can use sed(1):&lt;BR /&gt;a=/abc/efg&lt;BR /&gt;b=/qwerty&lt;BR /&gt;sed -e "s:\\($a$b\\):#\\1:" test &amp;gt; test.new</description>
      <pubDate>Thu, 14 Aug 2008 06:46:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-string-in-file/m-p/4251866#M331688</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-08-14T06:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: Replace string in file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-string-in-file/m-p/4251867#M331689</link>
      <description>Thanks dennis,&lt;BR /&gt;Appreciate your early help.&lt;BR /&gt;Its working fine.&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Aug 2008 06:53:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-string-in-file/m-p/4251867#M331689</guid>
      <dc:creator>chandregowda</dc:creator>
      <dc:date>2008-08-14T06:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: Replace string in file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-string-in-file/m-p/4251868#M331690</link>
      <description>Dennis&lt;BR /&gt;wat is the use of \\ in&lt;BR /&gt;sed -e "s:\\($a$b\\):#\\1:" test &amp;gt; test.new</description>
      <pubDate>Thu, 14 Aug 2008 06:57:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-string-in-file/m-p/4251868#M331690</guid>
      <dc:creator>chandregowda</dc:creator>
      <dc:date>2008-08-14T06:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Replace string in file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-string-in-file/m-p/4251869#M331691</link>
      <description>&amp;gt;Appreciate your early help.&lt;BR /&gt;&lt;BR /&gt;If our answers were helpful, please read the following about assigning points:&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/helptips.do?#33" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/helptips.do?#33&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;what is the use of \\ in:&lt;BR /&gt;sed -e "s:\\($a$b\\):#\\1:" test &amp;gt; test.new&lt;BR /&gt;&lt;BR /&gt;I assumed you didn't want to repeat $a$b twice and since you can use regular expressions to select pieces from the original string to add back in the replacement string, I used it.  Ordinarily you would like to use '' for sed and not "".  But because you want to use $a inside, you need "".  If you need to use "\", you need to double them.&lt;BR /&gt;&lt;BR /&gt;So your Regular Expression is:&lt;BR /&gt;s:\(stuff\):#\1:&lt;BR /&gt;&lt;BR /&gt;This puts "stuff", delimited by \( and \), back where you have the \1, preceded by a "#".  You can select multiple pieces and use \1, \2, to put them back, in any order you like.</description>
      <pubDate>Thu, 14 Aug 2008 07:07:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-string-in-file/m-p/4251869#M331691</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-08-14T07:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Replace string in file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-string-in-file/m-p/4251870#M331692</link>
      <description>How can write same using AWK command&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;gowda</description>
      <pubDate>Thu, 14 Aug 2008 07:20:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-string-in-file/m-p/4251870#M331692</guid>
      <dc:creator>chandregowda</dc:creator>
      <dc:date>2008-08-14T07:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Replace string in file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-string-in-file/m-p/4251871#M331693</link>
      <description>&amp;gt;How can write same using AWK command?&lt;BR /&gt;&lt;BR /&gt;Since it is too hard to use "" with awk, you use -v to pass in a variable:&lt;BR /&gt;awk -v STR="$a$b" '&lt;BR /&gt;{&lt;BR /&gt;sub(STR, "#" STR)&lt;BR /&gt;print $0&lt;BR /&gt;}' text</description>
      <pubDate>Thu, 14 Aug 2008 07:28:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-string-in-file/m-p/4251871#M331693</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-08-14T07:28:20Z</dc:date>
    </item>
  </channel>
</rss>

