<?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 extracting a portion from a file in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119928#M849404</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have a file of around 500 lines. I want to extract a portion of the file say from the line with the pattern 'abc' to the line with pattern 'efg' which might span for around 100 lines and redirect the output to a file. In case the file has got more occurances of the combination, the script should be able to extract all of them and dump into separate files.&lt;BR /&gt;&lt;BR /&gt;Can anyone please help me in this problem.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Andy</description>
    <pubDate>Fri, 14 Nov 2003 19:41:12 GMT</pubDate>
    <dc:creator>Anand_30</dc:creator>
    <dc:date>2003-11-14T19:41:12Z</dc:date>
    <item>
      <title>extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119928#M849404</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have a file of around 500 lines. I want to extract a portion of the file say from the line with the pattern 'abc' to the line with pattern 'efg' which might span for around 100 lines and redirect the output to a file. In case the file has got more occurances of the combination, the script should be able to extract all of them and dump into separate files.&lt;BR /&gt;&lt;BR /&gt;Can anyone please help me in this problem.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Andy</description>
      <pubDate>Fri, 14 Nov 2003 19:41:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119928#M849404</guid>
      <dc:creator>Anand_30</dc:creator>
      <dc:date>2003-11-14T19:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119929#M849405</link>
      <description>I think something like this will do the job....&lt;BR /&gt;&lt;BR /&gt;EXTRACT=N&lt;BR /&gt;NN=1&lt;BR /&gt;while read LINE&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;   echo $LINE|grep abc&lt;BR /&gt;&lt;BR /&gt;   if [ $? -eq 0 ]; then&lt;BR /&gt;      EXTRACT=Y&lt;BR /&gt;      OUTFILE=file${NN}&lt;BR /&gt;   fi&lt;BR /&gt;   &lt;BR /&gt;   echo $LINE|grep efg&lt;BR /&gt;   if [ $? -eq 0 ]; then&lt;BR /&gt;      EXTRACT=N&lt;BR /&gt;      NN=$(expr $NN + 1)&lt;BR /&gt;   fi&lt;BR /&gt;&lt;BR /&gt;   if [ "X${EXTRACT}" = "XY" ]; then&lt;BR /&gt;      echo $LINE &amp;gt; $OUTFILE&lt;BR /&gt;   fi&lt;BR /&gt;&lt;BR /&gt;done &amp;lt; mysourcefile.dat</description>
      <pubDate>Fri, 14 Nov 2003 20:50:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119929#M849405</guid>
      <dc:creator>James A. Donovan</dc:creator>
      <dc:date>2003-11-14T20:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119930#M849406</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;here an awk script:&lt;BR /&gt;BEGIN{COUNT=0;DOPRINT=0;}&lt;BR /&gt;/abc/ {DOPRINT=1;COUNT=COUNT+1;OUTPUTFILE="text." COUNT;}&lt;BR /&gt;{&lt;BR /&gt;  if (DOPRINT==1)&lt;BR /&gt;  {&lt;BR /&gt;    print $0 &amp;gt; OUTPUTFILE;&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;/efg/ {DOPRINT=0;}&lt;BR /&gt;END{}&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Sun, 16 Nov 2003 11:53:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119930#M849406</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2003-11-16T11:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119931#M849407</link>
      <description>Michael's solution will work, but there is an easier way with awk. &lt;BR /&gt;&lt;BR /&gt;awk '/abc/,/efg/' yourfile  &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;will print to a single file, but if you want a new file each time you hit abc it's a bit more involved.&lt;BR /&gt;&lt;BR /&gt;awk '&lt;BR /&gt;/abc/ {nf=sprintf("newfile.%d", ++matchcount)}&lt;BR /&gt;/abc/,/efg/ {print &amp;gt;&amp;gt;nf}&lt;BR /&gt;' yourfile &lt;BR /&gt;&lt;BR /&gt;This will create files called newfile.1, newfile.2 etc.&lt;BR /&gt;&lt;BR /&gt;-- Graham</description>
      <pubDate>Mon, 17 Nov 2003 06:59:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119931#M849407</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2003-11-17T06:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119932#M849408</link>
      <description>create a file called  extract.awk that includes the following:&lt;BR /&gt;&lt;BR /&gt;BEGIN {myflag=0;}&lt;BR /&gt;/abc/ {myflag=1;}&lt;BR /&gt;myflag==1 {print $0}&lt;BR /&gt;/def/ {exit;}&lt;BR /&gt;&lt;BR /&gt;Now run this as follows:&lt;BR /&gt;&lt;BR /&gt;awk -f extract.awk &amp;lt; inputfile &amp;gt; outputfile&lt;BR /&gt;&lt;BR /&gt;NOTE: The above will quit after the first occurrence of def following the first occurrence of abc.&lt;BR /&gt;&lt;BR /&gt;If you want to find multiple sections in a file (i.e. the lines from "abc" to "def" and then skipped some lines until we found another "abc" / "def" section.  Then just the change "exit" above to "myflag=0".&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;BR /&gt;Kent M. Ostby&lt;BR /&gt;</description>
      <pubDate>Mon, 17 Nov 2003 08:00:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119932#M849408</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2003-11-17T08:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119933#M849409</link>
      <description>Somebody should give Graham C.  10 points.&lt;BR /&gt;Rory</description>
      <pubDate>Mon, 17 Nov 2003 11:06:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119933#M849409</guid>
      <dc:creator>Rory R Hammond</dc:creator>
      <dc:date>2003-11-17T11:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119934#M849410</link>
      <description>Hi Graham,&lt;BR /&gt;&lt;BR /&gt;in case you havent noticed, mine is an awk script. ;-)&lt;BR /&gt;But yours is elegant and highly optimzed, very efficient a Borg would say. ;-)&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Mon, 17 Nov 2003 13:00:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119934#M849410</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2003-11-17T13:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119935#M849411</link>
      <description>Thanks all for your response. I faced a problem while using Graham's and Kent's solution. In my file there are multiple instances of the pattern 'abc' but few combinations of 'abc' and 'def'. I want the script only to extract the lines which start at 'abc' and end at 'def'. But currently the script extracts all the lines that start with 'abc' also.&lt;BR /&gt;&lt;BR /&gt;Looking forward for some help.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Andy</description>
      <pubDate>Mon, 17 Nov 2003 15:16:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119935#M849411</guid>
      <dc:creator>Anand_30</dc:creator>
      <dc:date>2003-11-17T15:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119936#M849412</link>
      <description>Are you saying that your file has:&lt;BR /&gt;&lt;BR /&gt;abc{other  stuff}def&lt;BR /&gt;&lt;BR /&gt;lines scattered in it and you only want the _lines_ that begin abc and end in edf?&lt;BR /&gt;&lt;BR /&gt;grep -e "^abc.*def$" myfile&lt;BR /&gt;&lt;BR /&gt;Will provide those lines.&lt;BR /&gt;&lt;BR /&gt;However, if your file is like &lt;BR /&gt;&lt;BR /&gt;abc (stuff)&lt;BR /&gt;more stuff&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;def (stuff)&lt;BR /&gt;&lt;BR /&gt;Then the scripts that have already should work.&lt;BR /&gt;&lt;BR /&gt;If your expect to have &lt;BR /&gt;&lt;BR /&gt;abc stuff&lt;BR /&gt;more stuff&lt;BR /&gt;def&lt;BR /&gt;more stuff&lt;BR /&gt;abc stuff&lt;BR /&gt;more stuff&lt;BR /&gt;def &lt;BR /&gt;&lt;BR /&gt;and you want each block listed,then try modifying the submitted scripts so that a abc match turns on the print flag and a def turns it off.&lt;BR /&gt;&lt;BR /&gt;In perl it would look like&lt;BR /&gt;&lt;BR /&gt;#!/usr/local/bin/perl -w&lt;BR /&gt;&lt;BR /&gt;use IO::File;&lt;BR /&gt;&lt;BR /&gt;$printit=0;&lt;BR /&gt;&lt;BR /&gt;    $filename=shift(@ARGV);&lt;BR /&gt;    $file = new IO::File;&lt;BR /&gt;    $file-&amp;gt;open("&amp;lt;$filename");&lt;BR /&gt;&lt;BR /&gt;    while( ($linein=$file-&amp;gt;getline) ){&lt;BR /&gt;&lt;BR /&gt;        if ($linein =~ /abc/){&lt;BR /&gt;           printit=1;&lt;BR /&gt;        }&lt;BR /&gt;&lt;BR /&gt;        if (printit == 1){&lt;BR /&gt;           print "$linein\n";&lt;BR /&gt;           if($linein=~ /def/){&lt;BR /&gt;              printit=0;&lt;BR /&gt;           }&lt;BR /&gt;        }&lt;BR /&gt;    }&lt;BR /&gt;    $file-&amp;gt;close;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;run it with  my_script my_file&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 17 Nov 2003 16:56:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119936#M849412</guid>
      <dc:creator>R. Allan Hicks</dc:creator>
      <dc:date>2003-11-17T16:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119937#M849413</link>
      <description>My file is like this:&lt;BR /&gt;&lt;BR /&gt;abc&lt;BR /&gt;some stuff&lt;BR /&gt;...&lt;BR /&gt;..&lt;BR /&gt;def&lt;BR /&gt;abc&lt;BR /&gt;some stuff&lt;BR /&gt;abc&lt;BR /&gt;some stuff&lt;BR /&gt;abc&lt;BR /&gt;some stuff&lt;BR /&gt;abc&lt;BR /&gt;some stuff&lt;BR /&gt;...&lt;BR /&gt;..&lt;BR /&gt;def&lt;BR /&gt;&lt;BR /&gt;I want the script to extract the portion of the file which starts with the pattern 'abc' and ends with the pattern def. But now the scripts extracts the lines that starts with 'abc' also.&lt;BR /&gt;&lt;BR /&gt;In some files there are only one occurance of 'abc' and 'def'. In those cases the scripts work exactly fine. &lt;BR /&gt;&lt;BR /&gt;-Andy&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 17 Nov 2003 17:16:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119937#M849413</guid>
      <dc:creator>Anand_30</dc:creator>
      <dc:date>2003-11-17T17:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119938#M849414</link>
      <description>If your saying your file has multiple "abc" lines that may or may not have matching "efg" lines and you only want the "abc" lines that are closest to the "efg".&lt;BR /&gt; &lt;BR /&gt;Example-&lt;BR /&gt;1 abc one&lt;BR /&gt;2 abc two&lt;BR /&gt;3 something&lt;BR /&gt;4 def one&lt;BR /&gt; &lt;BR /&gt;And you want lines 2 - 4, then maybe this one line perl script can do it.&lt;BR /&gt;&lt;BR /&gt;perl -ne 'if (/abc/) { @a=(); $p=1; } ;  { push(@a,$_); }; if (/efg/) { print @a if $p; @a=(); $p=0 }' yourfile&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 17 Nov 2003 17:23:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119938#M849414</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-11-17T17:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119939#M849415</link>
      <description>Looks like I confused "def" and "efg". Just replace "def" with all "efg" in my response.&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 17 Nov 2003 17:25:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119939#M849415</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-11-17T17:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119940#M849416</link>
      <description>Thanks Rod,&lt;BR /&gt;&lt;BR /&gt;This seems to work fine but I want each extract to be put in a separate file. How can I accomplish that.&lt;BR /&gt;&lt;BR /&gt;-Andy</description>
      <pubDate>Mon, 17 Nov 2003 18:05:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119940#M849416</guid>
      <dc:creator>Anand_30</dc:creator>
      <dc:date>2003-11-17T18:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119941#M849417</link>
      <description>This will open a new file for each "block"-&lt;BR /&gt; &lt;BR /&gt;perl -ne 'if (/abc/) { @a=(); $p=1; } ; { push(@a,$_); }; if (/efg/) { if ($p) { $n++; open OUT "&amp;gt;outfile.$n"; print @a; close OUT; @a=(); $p=0 }' yourfile&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 17 Nov 2003 18:13:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119941#M849417</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-11-17T18:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119942#M849418</link>
      <description>Oops, I needed another "}"&lt;BR /&gt; &lt;BR /&gt;perl -ne 'if (/abc/) { @a=(); $p=1; } ; { push(@a,$_); }; if (/efg/) { if ($p) { $n++; open OUT "&amp;gt;outfile.$n"; print @a; close OUT; @a=(); $p=0 }}' yourfile&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 17 Nov 2003 18:14:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119942#M849418</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-11-17T18:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119943#M849419</link>
      <description>I am getting the following error while executing the script:&lt;BR /&gt;&lt;BR /&gt;Missing comma after first argument to open function at -e line 1, near ""&amp;gt;outfil&lt;BR /&gt;e.$n";"&lt;BR /&gt;Execution of -e aborted due to compilation errors&lt;BR /&gt;&lt;BR /&gt;Can you please help me out in this&lt;BR /&gt;&lt;BR /&gt;-Andy</description>
      <pubDate>Mon, 17 Nov 2003 18:32:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119943#M849419</guid>
      <dc:creator>Anand_30</dc:creator>
      <dc:date>2003-11-17T18:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119944#M849420</link>
      <description>Michael&lt;BR /&gt;&lt;BR /&gt;Mine is an awk script too.&lt;BR /&gt;&lt;BR /&gt;Andy, so you want to &lt;BR /&gt;- start capturing when you hit abc&lt;BR /&gt;- if you hit another abc, start capturing again.&lt;BR /&gt;- when you hit a def, print all lines since the most recent abc&lt;BR /&gt;&lt;BR /&gt;Here goes. I am doing this via a script file rather than in-line:&lt;BR /&gt;&lt;BR /&gt;Create a file, eg andy.awk, containing:&lt;BR /&gt;&lt;BR /&gt;/^abc/ {&lt;BR /&gt;   split("",list) #empty out the array.&lt;BR /&gt;   el=0&lt;BR /&gt;   list [++el] = $0&lt;BR /&gt;   next }&lt;BR /&gt;(el &amp;gt; 0) { list [++el] = $0 }&lt;BR /&gt;/^def/ {&lt;BR /&gt;   nf=sprintf("newfile.%d", ++matchcount)&lt;BR /&gt;   for (i=1;i&amp;lt;=el;i++)&lt;BR /&gt;      print list[i] &amp;gt;&amp;gt; nf&lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;Invoke this with awk -f andy.awk yourfile, it will create newfile.1, newfile.2 etc.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hope that closes it.&lt;BR /&gt;&lt;BR /&gt;-- Graham</description>
      <pubDate>Tue, 18 Nov 2003 03:27:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119944#M849420</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2003-11-18T03:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119945#M849421</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;BEGIN{COUNT=0;DOPRINT=0;}&lt;BR /&gt;/abc/\&lt;BR /&gt;{if (DOPRINT==0)&lt;BR /&gt;{&lt;BR /&gt;  DOPRINT=1;&lt;BR /&gt;  COUNT=COUNT+1;&lt;BR /&gt;  OUTPUTFILE="text." COUNT;&lt;BR /&gt;}&lt;BR /&gt;{&lt;BR /&gt;if (DOPRINT==1)&lt;BR /&gt;{&lt;BR /&gt;print $0 &amp;gt; OUTPUTFILE;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;/efg/ {DOPRINT=0;}&lt;BR /&gt;END{}&lt;BR /&gt;&lt;BR /&gt;this should do the trick.&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael</description>
      <pubDate>Tue, 18 Nov 2003 05:07:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119945#M849421</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2003-11-18T05:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119946#M849422</link>
      <description>Into a single file:&lt;BR /&gt;&lt;BR /&gt;# perl -ne '/abc/.../efg/ and print' file&amp;gt;excerpt&lt;BR /&gt;&lt;BR /&gt;What I dont see in your quest is what should hppen when matches overlap&lt;BR /&gt;&lt;BR /&gt;abc&lt;BR /&gt;x&lt;BR /&gt;abc&lt;BR /&gt;efg&lt;BR /&gt;efg&lt;BR /&gt;&lt;BR /&gt;that's the diff in perl between /pat/../pat/ and /pat/.../pat/ both not very well know options. Unless you state what your wish is about overlapping matches, it's hard to split into different files.&lt;BR /&gt;&lt;BR /&gt;Basics could be like:&lt;BR /&gt;&lt;BR /&gt;if (/abc/../def/) {&lt;BR /&gt; unless ($out) { open $out, "&amp;gt;file$." or die "file$.: $!" }&lt;BR /&gt; print $out;&lt;BR /&gt; }&lt;BR /&gt;else {&lt;BR /&gt; $out and close $out;&lt;BR /&gt; undef $out;&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;Which is far more easy than the previous posted perl solutions. Rodney's solutions are correct and simple (as usual), but I think I should at least draw they attention to these lesser known, but very powerful features.&lt;BR /&gt;&lt;BR /&gt;Enjoy, have FUN! H.Merijn</description>
      <pubDate>Tue, 18 Nov 2003 05:52:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119946#M849422</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-11-18T05:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: extracting a portion from a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119947#M849423</link>
      <description>Hi Andy,&lt;BR /&gt;&lt;BR /&gt;have you checked on the latest posts?&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Nov 2003 12:47:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/extracting-a-portion-from-a-file/m-p/3119947#M849423</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2003-11-18T12:47:16Z</dc:date>
    </item>
  </channel>
</rss>

