<?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: grep command - help needed in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099020#M807396</link>
    <description>Andy,&lt;BR /&gt;&lt;BR /&gt;   You can still use grep then pipe the stdout to head -n for number of lines to display.&lt;BR /&gt;&lt;BR /&gt;grep &lt;PATTERN&gt; file | head -20&lt;BR /&gt;&lt;BR /&gt;Would display the first 20 lines grep returned.&lt;BR /&gt;&lt;BR /&gt;   CIAO&lt;/PATTERN&gt;</description>
    <pubDate>Thu, 23 Oct 2003 12:25:40 GMT</pubDate>
    <dc:creator>Jack Werner</dc:creator>
    <dc:date>2003-10-23T12:25:40Z</dc:date>
    <item>
      <title>grep command - help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099011#M807387</link>
      <description>Is there any option in grep which helps me to search for a particular pattern and then display 'n' lines after that. I am using &lt;BR /&gt;HP-UX10.20. In linux it can be done using &lt;BR /&gt;'grep -A n' option.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Andy&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Oct 2003 17:18:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099011#M807387</guid>
      <dc:creator>Anand_30</dc:creator>
      <dc:date>2003-10-21T17:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: grep command - help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099012#M807388</link>
      <description>There is no such option in grep. It would be easy to do in awk. There is an extreme reluctance in UNIX (unlike Linux) to 'improve' commands which have literally been around for decades. It tends to make things very unportable.&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Oct 2003 17:40:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099012#M807388</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-10-21T17:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: grep command - help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099013#M807389</link>
      <description>Thanks,&lt;BR /&gt;&lt;BR /&gt;How do I do it using awk. Can you provide some examples.&lt;BR /&gt;&lt;BR /&gt;-Andy</description>
      <pubDate>Tue, 21 Oct 2003 17:59:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099013#M807389</guid>
      <dc:creator>Anand_30</dc:creator>
      <dc:date>2003-10-21T17:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: grep command - help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099014#M807390</link>
      <description>cat yourfile |&lt;BR /&gt;awk '{&lt;BR /&gt;if ( $0 ~ /yourpattern/ ) {&lt;BR /&gt;for ( i=0; i&lt;NUMBEROFLINES&gt;&lt;/NUMBEROFLINES&gt;getline;&lt;BR /&gt;print $0;&lt;BR /&gt;}}}'</description>
      <pubDate>Tue, 21 Oct 2003 19:14:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099014#M807390</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-10-21T19:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: grep command - help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099015#M807391</link>
      <description>Andy -&lt;BR /&gt;As much as I would like to see the awk solution as well, this is a technique I have used.&lt;BR /&gt;You have the line number to start with from your grep -n so ....&lt;BR /&gt; sed -n "$your_line_number","$X_line_numbers_out"p $SCRIPT_HOME/$DATA_FILE &amp;gt; $OUT_FILE&lt;BR /&gt;&lt;BR /&gt;Or let starting_line="$your_line_number + 1"&lt;BR /&gt;    let ending_line="$your_line_number + 5"&lt;BR /&gt; sed -n "$starting_line","$ending_line"p $SCRIPT_HOME/$DATA_FILE &amp;gt; $OUT_FILE&lt;BR /&gt;&lt;BR /&gt;Best of luck.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;dl</description>
      <pubDate>Tue, 21 Oct 2003 19:16:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099015#M807391</guid>
      <dc:creator>Dave La Mar</dc:creator>
      <dc:date>2003-10-21T19:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: grep command - help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099016#M807392</link>
      <description>Why not just fetch GNU grep for 10.20 from my site, and you have the same as Linux :)&lt;BR /&gt; &lt;BR /&gt;&lt;A href="https://www.beepz.com/personal/merijn/" target="_blank"&gt;https://www.beepz.com/personal/merijn/&lt;/A&gt; , &lt;A href="http://www.cmve.net/~merijn/" target="_blank"&gt;http://www.cmve.net/~merijn/&lt;/A&gt; , or or &lt;A href="http://www.hpux.ws/merijn/" target="_blank"&gt;http://www.hpux.ws/merijn/&lt;/A&gt;&lt;BR /&gt; &lt;BR /&gt;Enjoy, have FUN! H.Merijn</description>
      <pubDate>Tue, 21 Oct 2003 19:29:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099016#M807392</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-10-21T19:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: grep command - help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099017#M807393</link>
      <description>have you tried&lt;BR /&gt;&lt;BR /&gt;ex -s +"g/yourpattern/ .+1,.+numberOfLines |q" filename&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Oct 2003 19:36:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099017#M807393</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-10-21T19:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: grep command - help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099018#M807394</link>
      <description>oops forgot the p for print&lt;BR /&gt;&lt;BR /&gt;ex -s +"g/yourpattern/ .+1,.+numberOfLines p|q" filename</description>
      <pubDate>Tue, 21 Oct 2003 19:38:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099018#M807394</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-10-21T19:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: grep command - help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099019#M807395</link>
      <description>&lt;BR /&gt;Under OpenVMS the command would be:&lt;BR /&gt;&lt;BR /&gt;$SEARCH/WINDOW=(0,&lt;LINES&gt;) &lt;FILE&gt; &lt;STRING&gt;&lt;BR /&gt;&lt;BR /&gt;The 0 being 0 pre-fix lines. Surely you were all dying to know that huh?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In Tru64 you can often use -p for a 'paragraph'. No use there either huh?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I'm a bit dissapointed at the lack of extension in many hpux tools. I like the suggestion of just picking up GNU grep.&lt;BR /&gt;&lt;BR /&gt;In the mean time you coudl use AWK:&lt;BR /&gt;&lt;BR /&gt;awk '/&lt;STRING&gt;/{print $0; i=&lt;LINES&gt;; while (i--) {getline; print $0}}' &amp;lt; &lt;FILE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;or PERL (assuring a re-start every occurence:&lt;BR /&gt;&lt;BR /&gt;cat &lt;FILE&gt; | perl -e 'while (&amp;lt;&amp;gt;){$i=&lt;LINES&gt; if (/&lt;STRING&gt;/); print if ($i--&amp;gt;0)}'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/STRING&gt;&lt;/LINES&gt;&lt;/FILE&gt;&lt;/FILE&gt;&lt;/LINES&gt;&lt;/STRING&gt;&lt;/STRING&gt;&lt;/FILE&gt;&lt;/LINES&gt;</description>
      <pubDate>Tue, 21 Oct 2003 20:30:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099019#M807395</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2003-10-21T20:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: grep command - help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099020#M807396</link>
      <description>Andy,&lt;BR /&gt;&lt;BR /&gt;   You can still use grep then pipe the stdout to head -n for number of lines to display.&lt;BR /&gt;&lt;BR /&gt;grep &lt;PATTERN&gt; file | head -20&lt;BR /&gt;&lt;BR /&gt;Would display the first 20 lines grep returned.&lt;BR /&gt;&lt;BR /&gt;   CIAO&lt;/PATTERN&gt;</description>
      <pubDate>Thu, 23 Oct 2003 12:25:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grep-command-help-needed/m-p/3099020#M807396</guid>
      <dc:creator>Jack Werner</dc:creator>
      <dc:date>2003-10-23T12:25:40Z</dc:date>
    </item>
  </channel>
</rss>

