<?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: scripting help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465622#M360435</link>
    <description>I like that to!&lt;BR /&gt;&lt;BR /&gt;Amy thanks James and Patrick&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Thu, 23 Jul 2009 16:00:33 GMT</pubDate>
    <dc:creator>Rick Garland</dc:creator>
    <dc:date>2009-07-23T16:00:33Z</dc:date>
    <item>
      <title>scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465614#M360427</link>
      <description>Hi all:&lt;BR /&gt;&lt;BR /&gt;Been banging my head on this one and I can't find the right touch.&lt;BR /&gt;&lt;BR /&gt;I have output from a command that produces the following format;&lt;BR /&gt;&lt;BR /&gt;Handle&lt;BR /&gt;another line&lt;BR /&gt;another line&lt;BR /&gt;another line&lt;BR /&gt;&lt;BR /&gt;Handle &lt;BR /&gt;System Information&lt;BR /&gt;line 1&lt;BR /&gt;line 2&lt;BR /&gt;line 3&lt;BR /&gt;line 4&lt;BR /&gt;&lt;BR /&gt;Handle&lt;BR /&gt;another line&lt;BR /&gt;another line&lt;BR /&gt;another line&lt;BR /&gt;another line&lt;BR /&gt;&lt;BR /&gt;Handle&lt;BR /&gt;etc...&lt;BR /&gt;&lt;BR /&gt;What I am wanting to do is print everything between the lines of Handle but only if the pattern of System Information is matched. The rest of the data I do not want.&lt;BR /&gt;&lt;BR /&gt;I did come up with this and it works OK, but I know there is a better solution.&lt;BR /&gt;awk 'BEGIN { RS = "System Information" } END { RS = "" } {print $1, $2, $3, "\n" $4, $5, $6}'&lt;BR /&gt;&lt;BR /&gt;Like I said, this works OK but if the number of variables/lines changes then the print changes. What I really want is to print all lines (line 1, line 2, line 3 line n, ...) regardless of the number of lines. &lt;BR /&gt;&lt;BR /&gt;The shell can be either ksh or bash.&lt;BR /&gt;&lt;BR /&gt;Many thanks</description>
      <pubDate>Thu, 23 Jul 2009 13:03:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465614#M360427</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2009-07-23T13:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465615#M360428</link>
      <description>And what the heck, how about perl as well.</description>
      <pubDate>Thu, 23 Jul 2009 13:07:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465615#M360428</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2009-07-23T13:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465616#M360429</link>
      <description>Hi Rick:&lt;BR /&gt;&lt;BR /&gt;# perl -nle '$/="";print if m/Handle/ &amp;amp;&amp;amp; m/System/' file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 23 Jul 2009 13:59:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465616#M360429</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-07-23T13:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465617#M360430</link>
      <description>Thanks JRF!&lt;BR /&gt;Any thing for shell (using awk, sed, or something)?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Jul 2009 14:48:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465617#M360430</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2009-07-23T14:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465618#M360431</link>
      <description>One thing I do see I do not want with the perl syntax is that I do not want to print any of the lines after the next Handle. I only want the line 1, line 2, line 3 - the rest of the output (another line) I do not want.&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Jul 2009 14:52:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465618#M360431</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2009-07-23T14:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465619#M360432</link>
      <description>Found my answer with awk, at least.&lt;BR /&gt;awk '/System Information/,/Handle/' file&lt;BR /&gt;&lt;BR /&gt;This will print the line 1 line 2 line 3 line 4 line n... &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Jul 2009 15:25:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465619#M360432</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2009-07-23T15:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465620#M360433</link>
      <description>Hi (again) Rick:&lt;BR /&gt;&lt;BR /&gt;OK, you can do the same in 'awk' with:&lt;BR /&gt;&lt;BR /&gt;# awk 'BEGIN{RS=""};{if (/Handle/ &amp;amp;&amp;amp; /System/) {print}}' file&lt;BR /&gt;&lt;BR /&gt;&amp;gt; I only want the line 1, line 2, line 3 - the rest of the output (another line) I do not want.&lt;BR /&gt;&lt;BR /&gt;That changes things a bit since in either the Perl or 'awk' we have used the blank line to signal a record's endpoint.&lt;BR /&gt;&lt;BR /&gt;One kludge way would be to pipe the output of the 'awk' or 'perl' script to 'head -5'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Jul 2009 15:41:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465620#M360433</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-07-23T15:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465621#M360434</link>
      <description>&lt;!--!*#--&gt;How about a shell script with no awk or anything:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;while read LINE&lt;BR /&gt;do&lt;BR /&gt;  if [[ "${LINE}" = "Handle" ]] ; then&lt;BR /&gt;     HANDLE=1&lt;BR /&gt;  elif [[ "${LINE}" = "System Information" ]] ; then&lt;BR /&gt;     echo "Handle"&lt;BR /&gt;     echo ${LINE}&lt;BR /&gt;     SYSINF=0&lt;BR /&gt;     HANDLE=0&lt;BR /&gt;  elif [[ "${SYSINF}" = "0" &amp;amp;&amp;amp; "${HANDLE}" = "0" &amp;amp;&amp;amp; "${LINE}" != "" ]] ; then&lt;BR /&gt;     echo ${LINE}&lt;BR /&gt;  fi&lt;BR /&gt;done &amp;lt; testfile&lt;BR /&gt;&lt;BR /&gt;Running this, with your example data yields:&lt;BR /&gt;&lt;BR /&gt; $ sh ./test.sh&lt;BR /&gt;Handle&lt;BR /&gt;System Information&lt;BR /&gt;line 1&lt;BR /&gt;line 2&lt;BR /&gt;line 3&lt;BR /&gt;line 4&lt;BR /&gt; $</description>
      <pubDate>Thu, 23 Jul 2009 15:56:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465621#M360434</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2009-07-23T15:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465622#M360435</link>
      <description>I like that to!&lt;BR /&gt;&lt;BR /&gt;Amy thanks James and Patrick&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Jul 2009 16:00:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465622#M360435</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2009-07-23T16:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465623#M360436</link>
      <description>Hi (again) Rick:&lt;BR /&gt;&lt;BR /&gt;A bit better than the pipe to 'head' to snip any additional lines you don's want is this variation.  It also handles repetitive blocks that match:&lt;BR /&gt;&lt;BR /&gt;# perl -nle '$/="";if (m/Handle/ &amp;amp;&amp;amp; m/System/) {@a=m/(.+?$)(.+?$)(.+?$)(.+?$)(.+?$)/sm and print @a}' file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Jul 2009 16:11:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/4465623#M360436</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-07-23T16:11:08Z</dc:date>
    </item>
  </channel>
</rss>

