<?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 problem in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041801#M29427</link>
    <description>Hi (again) Declan:&lt;BR /&gt;&lt;BR /&gt;Sorry, I droppted a ".":&lt;BR /&gt;&lt;BR /&gt;# perl -pi.old -e ...&lt;BR /&gt;&lt;BR /&gt;Anyway, for your first-only block:&lt;BR /&gt;&lt;BR /&gt;# perl -0377 -pi.old -e 's/EXECUTE IMMEDIATE.+s_Return;(.+Declare.+)/NEW\nBLOCK\nHERE\1/s' file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 23 Jul 2007 10:06:12 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2007-07-23T10:06:12Z</dc:date>
    <item>
      <title>sed problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041796#M29422</link>
      <description>I have a small sed problem. Basically i am trying to do the following 3 things &lt;BR /&gt;&lt;BR /&gt;1) Search a file for a block of text&lt;BR /&gt;&lt;BR /&gt;2) Search a file for the first occurance of a string&lt;BR /&gt;&lt;BR /&gt;3) Insert a block of text&lt;BR /&gt;&lt;BR /&gt;I've tried various combonations of sed commands with little luck so any help appreciated&lt;BR /&gt;&lt;BR /&gt;Thanks in advance &lt;BR /&gt;&lt;BR /&gt;Declan</description>
      <pubDate>Mon, 23 Jul 2007 05:37:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041796#M29422</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2007-07-23T05:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: sed problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041797#M29423</link>
      <description>Try the following&lt;BR /&gt;&lt;BR /&gt;sed s/string_you_search_for/new_string\ string_you_search_for/ filename&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This should print on STDOUT the result. If you wish to modify the content of the file as well, then simply redirect the output to some file and then rename the new file to the name of the original file ( after you did a backup of the original file of course).&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 23 Jul 2007 07:19:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041797#M29423</guid>
      <dc:creator>Alexander Chuzhoy</dc:creator>
      <dc:date>2007-07-23T07:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: sed problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041798#M29424</link>
      <description>Alex, &lt;BR /&gt;&lt;BR /&gt;I only want to replace the first occurance of the word and i need to replace it with a block of text. &lt;BR /&gt;&lt;BR /&gt;my file is like this &lt;BR /&gt;&lt;BR /&gt;Declare&lt;BR /&gt;&lt;BR /&gt;Begin&lt;BR /&gt;&lt;BR /&gt;EXECUTE IMMEDIATE 'BEGIN WriteScriptsLogs( :2, :3, :4, :5, :6, :7, :8, :9 ); END;'&lt;BR /&gt;      USING IN s_Source, IN s_ScriptName, IN s_ScriptSetVer, IN s_SetRange, IN n_ScriptVer&lt;BR /&gt;        , IN s_Status, IN s_Message, OUT s_Return;&lt;BR /&gt;&lt;BR /&gt;End;&lt;BR /&gt;&lt;BR /&gt;I need to search for the EXECUTE IMMEDIATE block until the s_Return and replace it with another different block</description>
      <pubDate>Mon, 23 Jul 2007 07:36:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041798#M29424</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2007-07-23T07:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: sed problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041799#M29425</link>
      <description>Hi Declan:&lt;BR /&gt;&lt;BR /&gt;If you don't mind Perl:&lt;BR /&gt;&lt;BR /&gt;# perl -0377 -pe 's/EXECUTE IMMEDIATE.+s_Return/NEW\nBLOCK\nHERE/s' file&lt;BR /&gt;&lt;BR /&gt;If you would like to update the file "in-place", retraining an un-modified backup copy as "file.old", do:&lt;BR /&gt;&lt;BR /&gt;# perl -0377 -p.old -e 's/EXECUTE IMMEDIATE.+s_Return/NEW\nBLOCK\nHERE/s' file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 23 Jul 2007 08:36:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041799#M29425</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-07-23T08:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: sed problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041800#M29426</link>
      <description>Thanks James,&lt;BR /&gt;&lt;BR /&gt;I don't mind using perl but i had to change the command slightly by removing the .old after the -p otherwise i got the following error&lt;BR /&gt;&lt;BR /&gt;Unrecognized switch: -.old  (-h will show valid options).&lt;BR /&gt;&lt;BR /&gt;now i output the result to a second file&lt;BR /&gt;&lt;BR /&gt;any idea how to search for the first occurance of a word in the same file i.e. if i have multiple blocks which are the same?</description>
      <pubDate>Mon, 23 Jul 2007 08:58:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041800#M29426</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2007-07-23T08:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: sed problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041801#M29427</link>
      <description>Hi (again) Declan:&lt;BR /&gt;&lt;BR /&gt;Sorry, I droppted a ".":&lt;BR /&gt;&lt;BR /&gt;# perl -pi.old -e ...&lt;BR /&gt;&lt;BR /&gt;Anyway, for your first-only block:&lt;BR /&gt;&lt;BR /&gt;# perl -0377 -pi.old -e 's/EXECUTE IMMEDIATE.+s_Return;(.+Declare.+)/NEW\nBLOCK\nHERE\1/s' file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 23 Jul 2007 10:06:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041801#M29427</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-07-23T10:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: sed problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041802#M29428</link>
      <description>Hi (again) Declan:&lt;BR /&gt;&lt;BR /&gt;Actually, I prefer:&lt;BR /&gt;&lt;BR /&gt;# perl -0377 -pi.old -e 's/(EXECUTE IMMEDIATE.+s_Return;)(?=.+EXECUTE IMMEDIATE.+s_Return;)/NEW\nBLOCK\nHERE/s' file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 23 Jul 2007 11:16:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041802#M29428</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-07-23T11:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: sed problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041803#M29429</link>
      <description>Thanks James, &lt;BR /&gt;&lt;BR /&gt;I'll give this a whirl asap and assign point.&lt;BR /&gt;&lt;BR /&gt;Thanks again</description>
      <pubDate>Mon, 23 Jul 2007 11:26:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041803#M29429</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2007-07-23T11:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: sed problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041804#M29430</link>
      <description>Hi Declan:&lt;BR /&gt;&lt;BR /&gt;Disregard yesterday's bungles, please.  I was not thinking clearly at all!  The following should work for one or n-blocks of text as you have shown:&lt;BR /&gt;&lt;BR /&gt;# perl -0377 -pi.old -e 's/(EXECUTE IMMEDIATE.+?s_Return;)/NEW\nBLOCK\nHERE/s' file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 24 Jul 2007 06:46:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041804#M29430</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-07-24T06:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: sed problem</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041805#M29431</link>
      <description>Nice one James that works a treat (only thing was i had to double quote the string)&lt;BR /&gt;&lt;BR /&gt;Thanks again</description>
      <pubDate>Tue, 24 Jul 2007 08:09:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-problem/m-p/4041805#M29431</guid>
      <dc:creator>Declan Heerey</dc:creator>
      <dc:date>2007-07-24T08:09:47Z</dc:date>
    </item>
  </channel>
</rss>

