<?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 challenge in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230878#M172071</link>
    <description>You can get it here and it is a drop in replacement for HPUX grep.  It is completely compatible with HPUX grep only it's a lot better.   Existing scripts that grep will not notice the difference.  However, if you were worried, you could always copy your original grep somewhere else and just use a different path to it.&lt;BR /&gt; &lt;BR /&gt;&lt;A href="http://hpux.connect.org.uk/hppd/hpux/Gnu/grep-2.5.1/" target="_blank"&gt;http://hpux.connect.org.uk/hppd/hpux/Gnu/grep-2.5.1/&lt;/A&gt;</description>
    <pubDate>Fri, 26 Mar 2004 06:59:38 GMT</pubDate>
    <dc:creator>Mark Grant</dc:creator>
    <dc:date>2004-03-26T06:59:38Z</dc:date>
    <item>
      <title>Scripting challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230872#M172065</link>
      <description>We have a number of jobs that run on 200+ systems fetching info back into a file. This looks something like:&lt;BR /&gt;&lt;BR /&gt;gb656_1&lt;BR /&gt;/usr4/SDF&lt;BR /&gt;/usr4/LXD&lt;BR /&gt;/usr4/DFG&lt;BR /&gt;&lt;BR /&gt;gb650_1&lt;BR /&gt;/usr4/FGH&lt;BR /&gt;/usr4/OIU&lt;BR /&gt;&lt;BR /&gt;What I want to do is grep for a specific /usr4/??? line in the file. This is fine but is there anyway that same grep command could display the line plus a certain number of lines above/below the line I am grepping for? Basically as well as telling me the line exists I would also like to display the server (gb656_1) it is associated with.&lt;BR /&gt;&lt;BR /&gt;Any ideas?</description>
      <pubDate>Fri, 26 Mar 2004 06:28:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230872#M172065</guid>
      <dc:creator>Matthew Pegge_1</dc:creator>
      <dc:date>2004-03-26T06:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230873#M172066</link>
      <description>If you can get hold of GNU grep (it might be the same as on HPUX but I'm a bit HPUX challenged today so can't confirm) you can use the -A and -B which show you a few line of context before and after the match as in&lt;BR /&gt; &lt;BR /&gt;grep -B 3 LXD &lt;FILENAME&gt; in your case.&lt;/FILENAME&gt;</description>
      <pubDate>Fri, 26 Mar 2004 06:33:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230873#M172066</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-03-26T06:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230874#M172067</link>
      <description># perl -ne'BEGIN{$p=shift}m{^([^/]+)} and$d=$1;/$p/ and print "$d:$_"' pattern file&lt;BR /&gt;&lt;BR /&gt;You can also use the extended features of GNU grep, which is MUCH better than the grep you get from HP&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Fri, 26 Mar 2004 06:33:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230874#M172067</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-03-26T06:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230875#M172068</link>
      <description>Hi,&lt;BR /&gt;try running the attached script with 3 params:&lt;BR /&gt;$1=the string to search for&lt;BR /&gt;$2=the number of lines to print before and after $1&lt;BR /&gt;$3=inputfile &lt;BR /&gt; &lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Fri, 26 Mar 2004 06:55:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230875#M172068</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2004-03-26T06:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230876#M172069</link>
      <description>The GNU grep you talked about? Where do you get it from does it stop the HPUX grep from functioning? etc..&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Mar 2004 06:56:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230876#M172069</guid>
      <dc:creator>Matthew Pegge_1</dc:creator>
      <dc:date>2004-03-26T06:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230877#M172070</link>
      <description>GNU grep available from my site:&lt;BR /&gt;&lt;BR /&gt;Singapore &lt;A href="https://www.beepz.com/personal/merijn/" target="_blank"&gt;https://www.beepz.com/personal/merijn/&lt;/A&gt;&lt;BR /&gt;Rotterdam &lt;A href="http://www.cmve.net/~merijn/" target="_blank"&gt;http://www.cmve.net/~merijn/&lt;/A&gt;&lt;BR /&gt;Seattle   &lt;A href="http://ww.hpux.ws/merijn/" target="_blank"&gt;http://ww.hpux.ws/merijn/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;or from &lt;A href="http://hpux.connect.org.uk/hppd/hpux/Gnu/grep-2.5.1/" target="_blank"&gt;http://hpux.connect.org.uk/hppd/hpux/Gnu/grep-2.5.1/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;in order to have it overrule HP's grep, just e sure to have your $PATH changed so that it finds GNU grep before HP's grep &lt;BR /&gt;&lt;BR /&gt;Enjoy, have FUN! H.Merijn</description>
      <pubDate>Fri, 26 Mar 2004 06:59:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230877#M172070</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-03-26T06:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230878#M172071</link>
      <description>You can get it here and it is a drop in replacement for HPUX grep.  It is completely compatible with HPUX grep only it's a lot better.   Existing scripts that grep will not notice the difference.  However, if you were worried, you could always copy your original grep somewhere else and just use a different path to it.&lt;BR /&gt; &lt;BR /&gt;&lt;A href="http://hpux.connect.org.uk/hppd/hpux/Gnu/grep-2.5.1/" target="_blank"&gt;http://hpux.connect.org.uk/hppd/hpux/Gnu/grep-2.5.1/&lt;/A&gt;</description>
      <pubDate>Fri, 26 Mar 2004 06:59:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230878#M172071</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-03-26T06:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230879#M172072</link>
      <description>Thanks Guys! That just about sorts it out both short and long term!! You're all great!</description>
      <pubDate>Fri, 26 Mar 2004 07:17:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230879#M172072</guid>
      <dc:creator>Matthew Pegge_1</dc:creator>
      <dc:date>2004-03-26T07:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230880#M172073</link>
      <description>If you don't want to (or can't) get GNU grep, it can be done with awk. &lt;BR /&gt;The tricky bit is the lines before the pattern, which have to be kept in a buffer.&lt;BR /&gt;To show 10 lines before, 8 after, use something like:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;awk -v before=10 -v after=8 '&lt;BR /&gt;{ibuf[NR]=$0}&lt;BR /&gt;/\/user4\/xxx/ {for (i=NR-before;i&lt;NR&gt;&lt;/NR&gt;split ("", ibuf) # Clear the array&lt;BR /&gt;counter=after+1}&lt;BR /&gt;(counter&amp;gt;0) {counter--;print}&lt;BR /&gt;' YOURFILE&lt;BR /&gt;&lt;BR /&gt;This isn't terribly efficient as it saves every line in a buffer, although it does clear the buffer out each time it encounters the search string.&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Mar 2004 07:38:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230880#M172073</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2004-03-26T07:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230881#M172074</link>
      <description>&lt;BR /&gt;Matthew,&lt;BR /&gt;&lt;BR /&gt;Sounds like all you had to do is teach awk (or perl) to remember the lastserver node seen and report that upon match:&lt;BR /&gt;&lt;BR /&gt;awk '/^[^\/]/{node=$0} /FGH/{print node " : " $0}' x&lt;BR /&gt;gb650_1 : /usr4/FGH&lt;BR /&gt;&lt;BR /&gt;Graham wrote:&lt;BR /&gt; " The tricky bit is the lines before the pattern, which have to be kept in a buffer."&lt;BR /&gt;  : &lt;BR /&gt; " This isn't terribly efficient as it saves every line in a buffer"&lt;BR /&gt;&lt;BR /&gt;Using the modulus operator "%" it is trivial to create a small 'circular' buffer. See below.&lt;BR /&gt;&lt;BR /&gt;  ", although it does clear the buffer out each time it encounters the search string."&lt;BR /&gt;&lt;BR /&gt;That might not be desritable in case you can have two matches within the selected window size.&lt;BR /&gt;&lt;BR /&gt;Here is a one-line 'circular buffer" example with windows size in variable W (4):&lt;BR /&gt;&lt;BR /&gt;awk 'BEGIN {W=4} {line[i++%W]=$0} /FGH/{for (j=i-W;j&lt;I&gt;&lt;BR /&gt;hth someone,&lt;BR /&gt;Hein.&lt;/I&gt;</description>
      <pubDate>Fri, 26 Mar 2004 09:56:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3230881#M172074</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-03-26T09:56:25Z</dc:date>
    </item>
  </channel>
</rss>

