<?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 on hp-ux in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-on-hp-ux/m-p/4576147#M679204</link>
    <description>Hi James,&lt;BR /&gt;Many thanks for the solution. I got the answer as needed.&lt;BR /&gt;&lt;BR /&gt;Lets say if we have ;[BEG_INCLUDE]%I .... ;[END_INCLUDE] instead of BEGIN...END respectively.&lt;BR /&gt;&lt;BR /&gt;For example &lt;BR /&gt;test1&lt;BR /&gt;test2&lt;BR /&gt;test3&lt;BR /&gt;;BEG_INCLUDE]%I Begin&lt;BR /&gt;test4&lt;BR /&gt;test5&lt;BR /&gt;test6&lt;BR /&gt;;[END_INCLUDE]&lt;BR /&gt;test7&lt;BR /&gt;test8&lt;BR /&gt;test9&lt;BR /&gt;;[BEG_INCLUDE]%I Begin&lt;BR /&gt;test10&lt;BR /&gt;test11&lt;BR /&gt;;[END_INCLUDE]&lt;BR /&gt;&lt;BR /&gt;When I tried with your perl statement it said&lt;BR /&gt;# perl -ne (/^\;\[BEG_INCLUDE\]\%I/../^\;\[END_INCLUDE\]/) {next unless /^\;\[BEG_INCLUDE\]\%I/};print' test_include.txt &lt;BR /&gt;ksh: syntax error: `(' unexpected&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# perl -ne (/^;[BEG_INCLUDE]%I/../^;[END_INCLUDE]/) {next unless /^;[BEG_INCLUDE]%I/};print' test_include.txt &lt;BR /&gt;ksh: syntax error: `(' unexpected&lt;BR /&gt;&lt;BR /&gt;Thanks in advance</description>
    <pubDate>Tue, 02 Feb 2010 13:23:50 GMT</pubDate>
    <dc:creator>chrkc</dc:creator>
    <dc:date>2010-02-02T13:23:50Z</dc:date>
    <item>
      <title>using sed on hp-ux</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-on-hp-ux/m-p/4576145#M679202</link>
      <description>I have a file named "test.txt" in which I have the contents as&lt;BR /&gt;&lt;BR /&gt;test1&lt;BR /&gt;test2&lt;BR /&gt;test3&lt;BR /&gt;BEGIN&lt;BR /&gt;test4&lt;BR /&gt;test5&lt;BR /&gt;test6&lt;BR /&gt;END&lt;BR /&gt;test7&lt;BR /&gt;test8&lt;BR /&gt;test9&lt;BR /&gt;BEGIN&lt;BR /&gt;test10&lt;BR /&gt;test11&lt;BR /&gt;END&lt;BR /&gt;----&lt;BR /&gt;&lt;BR /&gt;Now I want to have the file modified in such a way that what ever is there in between BEGIN and END should be deleted provided BEGIN statement should exist.&lt;BR /&gt;&lt;BR /&gt;The output should be &lt;BR /&gt;---&lt;BR /&gt;test1&lt;BR /&gt;test2&lt;BR /&gt;test3&lt;BR /&gt;BEGIN&lt;BR /&gt;test7&lt;BR /&gt;test8&lt;BR /&gt;test9&lt;BR /&gt;BEGIN&lt;BR /&gt;&lt;BR /&gt;using sed as &lt;BR /&gt;sed '/^BEGIN/,/^END/{//p;d;}' test.txt | sed '/^END/d'&lt;BR /&gt;I was able to perform well enough on other linux envirinments but not on hp-ux.&lt;BR /&gt;This statement is deleting BEGIN also.&lt;BR /&gt;&lt;BR /&gt;Please help me on this&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 02 Feb 2010 12:07:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-on-hp-ux/m-p/4576145#M679202</guid>
      <dc:creator>chrkc</dc:creator>
      <dc:date>2010-02-02T12:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: using sed on hp-ux</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-on-hp-ux/m-p/4576146#M679203</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Well, Perl makes this trivial:&lt;BR /&gt;&lt;BR /&gt;# perl -ne 'if (/^BEGIN/../^END/) {next unless /^BEGIN/};print' text.txt&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 02 Feb 2010 13:09:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-on-hp-ux/m-p/4576146#M679203</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-02-02T13:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: using sed on hp-ux</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-on-hp-ux/m-p/4576147#M679204</link>
      <description>Hi James,&lt;BR /&gt;Many thanks for the solution. I got the answer as needed.&lt;BR /&gt;&lt;BR /&gt;Lets say if we have ;[BEG_INCLUDE]%I .... ;[END_INCLUDE] instead of BEGIN...END respectively.&lt;BR /&gt;&lt;BR /&gt;For example &lt;BR /&gt;test1&lt;BR /&gt;test2&lt;BR /&gt;test3&lt;BR /&gt;;BEG_INCLUDE]%I Begin&lt;BR /&gt;test4&lt;BR /&gt;test5&lt;BR /&gt;test6&lt;BR /&gt;;[END_INCLUDE]&lt;BR /&gt;test7&lt;BR /&gt;test8&lt;BR /&gt;test9&lt;BR /&gt;;[BEG_INCLUDE]%I Begin&lt;BR /&gt;test10&lt;BR /&gt;test11&lt;BR /&gt;;[END_INCLUDE]&lt;BR /&gt;&lt;BR /&gt;When I tried with your perl statement it said&lt;BR /&gt;# perl -ne (/^\;\[BEG_INCLUDE\]\%I/../^\;\[END_INCLUDE\]/) {next unless /^\;\[BEG_INCLUDE\]\%I/};print' test_include.txt &lt;BR /&gt;ksh: syntax error: `(' unexpected&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# perl -ne (/^;[BEG_INCLUDE]%I/../^;[END_INCLUDE]/) {next unless /^;[BEG_INCLUDE]%I/};print' test_include.txt &lt;BR /&gt;ksh: syntax error: `(' unexpected&lt;BR /&gt;&lt;BR /&gt;Thanks in advance</description>
      <pubDate>Tue, 02 Feb 2010 13:23:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-on-hp-ux/m-p/4576147#M679204</guid>
      <dc:creator>chrkc</dc:creator>
      <dc:date>2010-02-02T13:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: using sed on hp-ux</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-on-hp-ux/m-p/4576148#M679205</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;You used:&lt;BR /&gt;&lt;BR /&gt;# perl -ne (/^;[BEG_INCLUDE]%I/../^;[END_INCLUDE]/) {next unless /^;[BEG_INCLUDE]%I/};print' test_include.txt &lt;BR /&gt;&lt;BR /&gt;...but it needs to be:&lt;BR /&gt;&lt;BR /&gt;# perl -ne 'if (/^;[BEG_INCLUDE]%I/../^;[END_INCLUDE]/) {next unless /^;[BEG_INCLUDE]%I/};print' test_include.txt&lt;BR /&gt;&lt;BR /&gt;...that is, you dropped the leading single quote after the options '-ne' and you lost the 'if'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 02 Feb 2010 13:37:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-on-hp-ux/m-p/4576148#M679205</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-02-02T13:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: using sed on hp-ux</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-on-hp-ux/m-p/4576149#M679206</link>
      <description>Oops my apologies.&lt;BR /&gt;Just overlooked at the syntax.&lt;BR /&gt;&lt;BR /&gt;Thanks a bunch!!&lt;BR /&gt;&lt;BR /&gt;I got the solution.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 02 Feb 2010 13:39:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-on-hp-ux/m-p/4576149#M679206</guid>
      <dc:creator>chrkc</dc:creator>
      <dc:date>2010-02-02T13:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: using sed on hp-ux</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-on-hp-ux/m-p/4576150#M679207</link>
      <description>&lt;!--!*#--&gt;&amp;gt; [...] well enough on other linux&lt;BR /&gt;&amp;gt; envirinments but not on hp-ux [...]&lt;BR /&gt;&lt;BR /&gt;If you prefer the way that GNU "sed" works,&lt;BR /&gt;then it should be possible to install and use&lt;BR /&gt;GNU "sed" on your HP-UX system, too.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.gnu.org/software/sed/" target="_blank"&gt;http://www.gnu.org/software/sed/&lt;/A&gt;</description>
      <pubDate>Tue, 02 Feb 2010 15:07:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-on-hp-ux/m-p/4576150#M679207</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2010-02-02T15:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: using sed on hp-ux</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-on-hp-ux/m-p/4576151#M679208</link>
      <description>You may want to just give up on sed to do this type of complex task.  Use perl or awk where you have a procedural language.&lt;BR /&gt;&lt;BR /&gt;It appears that your immediate problem is that your "//" doesn't particularly match anything predictable.  Though sed(1) says:&lt;BR /&gt;a /regular expression/ in the style of ed(1) modified thus:&lt;BR /&gt;And ed(1) says:&lt;BR /&gt;The null RE (for example, //) is equivalent to the last RE encountered.&lt;BR /&gt;&lt;BR /&gt;This implies your command is:&lt;BR /&gt;sed '/^BEGIN/,/^END/{/^END/p;d;}' ...&lt;BR /&gt;&lt;BR /&gt;So change it to:&lt;BR /&gt;sed '/^BEGIN/,/^END/{/^BEGIN/p;d;}' ...&lt;BR /&gt;&lt;BR /&gt;Which matches what JRF had to use in perl.</description>
      <pubDate>Wed, 03 Feb 2010 07:33:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-on-hp-ux/m-p/4576151#M679208</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-02-03T07:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: using sed on hp-ux</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-on-hp-ux/m-p/4576152#M679209</link>
      <description>Hi Dennis,&lt;BR /&gt;&lt;BR /&gt;Thanks for the idea.&lt;BR /&gt;Yes it worked perfectly with the sed you have suggested.&lt;BR /&gt;&lt;BR /&gt;Actually, I wrote a script that actually deletes the block of code in between&lt;BR /&gt;;[BEG_INCLUDE] %i filename.txt&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;;[END_INCLUDE]   &lt;BR /&gt;and replaces the string &lt;BR /&gt;;[BEG_INCLUDE] %i filename.txt to&lt;BR /&gt;%i filename.txt&lt;BR /&gt;&lt;BR /&gt;The script which I wrote as&lt;BR /&gt;&lt;BR /&gt;sed '/^\;\[BEG_INCLUDE\]\%I/,/^\;\[END_INCLUDE\]/{//p;d;}' $pgm_name | sed '/^\;\[END_INCLUDE\]/d'  &amp;gt; $Temp_Name&lt;BR /&gt;&lt;BR /&gt;sed 's/;\[BEG_INCLUDE\]\%I/\%I/g' $Temp_Name &amp;gt; $Wrk_Name&lt;BR /&gt;&lt;BR /&gt;These two statements performs the above said operation and was infact working on CentOS and all other Linux flavours but not at all on HP-UX korn shell.&lt;BR /&gt;&lt;BR /&gt;But now I understood better on sed and many thanks for the solution.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 03 Feb 2010 10:21:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-sed-on-hp-ux/m-p/4576152#M679209</guid>
      <dc:creator>chrkc</dc:creator>
      <dc:date>2010-02-03T10:21:25Z</dc:date>
    </item>
  </channel>
</rss>

