<?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: script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575388#M31078</link>
    <description>Thanks all for your great responses....&lt;BR /&gt;&lt;BR /&gt;Cheers...&lt;BR /&gt;Satish.</description>
    <pubDate>Thu, 06 Sep 2001 10:41:40 GMT</pubDate>
    <dc:creator>Satish Y</dc:creator>
    <dc:date>2001-09-06T10:41:40Z</dc:date>
    <item>
      <title>script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575378#M31068</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;   I am writing a script that finds error messages from logs. I am finding by greping error msg number. The thing I am looking for is I want to grep 2,3 extra lines(following  line containing my pattern). Can anybody tell me how to do that.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;&lt;BR /&gt;Note: I don't know perl. I want it without using perl.&lt;BR /&gt;&lt;BR /&gt;Cheers...&lt;BR /&gt;Satish.</description>
      <pubDate>Wed, 05 Sep 2001 09:07:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575378#M31068</guid>
      <dc:creator>Satish Y</dc:creator>
      <dc:date>2001-09-05T09:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575379#M31069</link>
      <description>Satish,&lt;BR /&gt;&lt;BR /&gt;Then you may want to use sed. Let's say your Error No is defined as $ERR and your pattern is $PATTERN, then use sed like this&lt;BR /&gt;&lt;BR /&gt;sed -n '/'$ERR'/,/'$PATTERN'/p' your_log_file&lt;BR /&gt;&lt;BR /&gt;This may not exactly give what you want. You can make some modifications to the above command and achive whatever you want.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 05 Sep 2001 09:14:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575379#M31069</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2001-09-05T09:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575380#M31070</link>
      <description>Hi Sridhar,&lt;BR /&gt;&lt;BR /&gt;  My error number and pattern r not different they r same, means i am using error number as my pattern.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Satish.</description>
      <pubDate>Wed, 05 Sep 2001 09:30:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575380#M31070</guid>
      <dc:creator>Satish Y</dc:creator>
      <dc:date>2001-09-05T09:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575381#M31071</link>
      <description>Just a try :&lt;BR /&gt;&lt;BR /&gt;# cat trick.awk&lt;BR /&gt;&lt;BR /&gt;BEGIN { pri = 0 }&lt;BR /&gt;{&lt;BR /&gt;  if ( match($0, PAT ) &amp;gt; 0 ) &lt;BR /&gt;    pri = 3&lt;BR /&gt;  if ( pri &amp;gt; 0 )&lt;BR /&gt;  {&lt;BR /&gt;    print&lt;BR /&gt;    pri = pri - 1&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# cat test.txt&lt;BR /&gt;&lt;BR /&gt;dkjh dfkgj hfgkdjh gdkj ghdkgjdf&lt;BR /&gt;df gkjhfgkfj kfjh dkfgj hdkgh fdkg&lt;BR /&gt;fdl gkjfldgkjdflgkjdfgl TARGET&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;&lt;BR /&gt;# awk -v PAT=TARGET -f trick.awk test.txt&lt;BR /&gt;&lt;BR /&gt;fdl gkjfldgkjdflgkjdfgl TARGET&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;may be you need to put the calling commandline in a script to pass PAT=$1 as a parameter.&lt;BR /&gt;Change "pri=3" if you want more lines after the hit.&lt;BR /&gt;&lt;BR /&gt;Volker</description>
      <pubDate>Wed, 05 Sep 2001 10:19:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575381#M31071</guid>
      <dc:creator>Volker Borowski</dc:creator>
      <dc:date>2001-09-05T10:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575382#M31072</link>
      <description>Give Volker the 10 points , it is only small and it works a treat, it will help me out a loads with a similar problem I have.</description>
      <pubDate>Wed, 05 Sep 2001 11:20:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575382#M31072</guid>
      <dc:creator>John Waller</dc:creator>
      <dc:date>2001-09-05T11:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575383#M31073</link>
      <description>You could use the GNU grep, found here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.gnu.org/software/grep/grep.html" target="_blank"&gt;http://www.gnu.org/software/grep/grep.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;With GNU grep you get a lot more options. The "-A 1" with the "-B 1" options will display the line before the matching line, the matching line, and then the trailing line.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Sep 2001 11:40:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575383#M31073</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2001-09-05T11:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575384#M31074</link>
      <description>Satish,&lt;BR /&gt;&lt;BR /&gt;It would be nice if you can cat few lines of your log file and tell us what you want to extract. Check up the following script.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;ERR=$1&lt;BR /&gt;LEN=$2&lt;BR /&gt;&lt;BR /&gt;/usr/bin/sed -n '/'$ERR'/,$p' your_log |sed -n '1,'$LEN'p' &lt;BR /&gt;&lt;BR /&gt;Now you can pass two arguments to this script&lt;BR /&gt;Arg1=Your Error Number and LEN=Number of lines you want to print.&lt;BR /&gt;&lt;BR /&gt;Let me know if this helped you.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 05 Sep 2001 14:16:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575384#M31074</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2001-09-05T14:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575385#M31075</link>
      <description>Thanks for all your responses,&lt;BR /&gt;&lt;BR /&gt;Thanks Volker for a nice script... &lt;BR /&gt;&lt;BR /&gt;Excellent Sridhar, it worked well...&lt;BR /&gt;I also want to grep 2 lines before the pattern, is it possible?...&lt;BR /&gt;One more thing I didn't understand what $p does in ur sed statement. Can u explain?.&lt;BR /&gt;&lt;BR /&gt;Waiting for reply....&lt;BR /&gt;&lt;BR /&gt;Cheers...&lt;BR /&gt;Sat.</description>
      <pubDate>Thu, 06 Sep 2001 05:20:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575385#M31075</guid>
      <dc:creator>Satish Y</dc:creator>
      <dc:date>2001-09-06T05:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575386#M31076</link>
      <description>Satish,&lt;BR /&gt;&lt;BR /&gt;Yes.. there is a straight method but I don't remember it now. I can tell you a work around.&lt;BR /&gt;&lt;BR /&gt;Try this way.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;ERR=$1&lt;BR /&gt;PRE=`echo "$2 + 1"|bc`&lt;BR /&gt;POST=$3&lt;BR /&gt;&lt;BR /&gt;/usr/bin/sed -n '1,/$ERR/p' your_log |tail -$PRE &amp;gt; result&lt;BR /&gt;&lt;BR /&gt;/usr/bin/sed -n '/'$ERR'/,$p' your_log |sed -n '2,'$POST'p' &amp;gt;&amp;gt; result&lt;BR /&gt;&lt;BR /&gt;p is the print macro in sed.&lt;BR /&gt;&lt;BR /&gt;I do not have a system in front of me. So I am not sure if it works.. But you can adjust and make it to work.&lt;BR /&gt;&lt;BR /&gt;-Sri&lt;BR /&gt;</description>
      <pubDate>Thu, 06 Sep 2001 06:23:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575386#M31076</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2001-09-06T06:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575387#M31077</link>
      <description>OK,&lt;BR /&gt;another try. This is difficult, because you need to store the lines before your hit, because you do not really know, if you'll need them.&lt;BR /&gt;... and if there is a double hit, you may not reprint an already printed line.&lt;BR /&gt;If you want do seperate the hits, you might insert&lt;BR /&gt;print "-------" &lt;BR /&gt;before you print DELTA2.&lt;BR /&gt;For more leading lines, add more DELTAx, but to handle the double hits correctly, the number of printed lines after the hit (pri=3) needs to be greater or equal the number of DELTAx lines.&lt;BR /&gt;&lt;BR /&gt;Hey these puzzles are fun :-)&lt;BR /&gt;&lt;BR /&gt;here we go:&lt;BR /&gt;#########################&lt;BR /&gt;BTW: Does anyone know, why this textbox is eliminating my leading blanks ?&lt;BR /&gt;&lt;BR /&gt;Volker&lt;BR /&gt;&lt;BR /&gt;# cat trick.awk&lt;BR /&gt;&lt;BR /&gt;BEGIN { pri = 0 }&lt;BR /&gt;{&lt;BR /&gt;  if ( match($0, PAT ) &amp;gt; 0 ) &lt;BR /&gt;  {&lt;BR /&gt;    if ( pri == 0 )&lt;BR /&gt;    {&lt;BR /&gt;    print DELTA2&lt;BR /&gt;    print DELTA1&lt;BR /&gt;    }&lt;BR /&gt;    pri = 3&lt;BR /&gt;  }&lt;BR /&gt;  if ( pri &amp;gt; 0 )&lt;BR /&gt;  {&lt;BR /&gt;    print&lt;BR /&gt;    pri = pri - 1&lt;BR /&gt;  }&lt;BR /&gt;  DELTA2 = DELTA1&lt;BR /&gt;  DELTA1 = $0&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# cat test.txt&lt;BR /&gt;&lt;BR /&gt;no printline&lt;BR /&gt;second before target 1 (easy)&lt;BR /&gt;first before target 1 (easy)&lt;BR /&gt;first:first TARGET garbage&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;no printline&lt;BR /&gt;no printline&lt;BR /&gt;no printline&lt;BR /&gt;second before target 2 (easy)&lt;BR /&gt;first before target 2 (easy)&lt;BR /&gt;second:second TARGET garbage&lt;BR /&gt;1&lt;BR /&gt;mean:mean TARGET garbage&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;no printline&lt;BR /&gt;no printline&lt;BR /&gt;no printline&lt;BR /&gt;no printline&lt;BR /&gt;&lt;BR /&gt;# awk -v PAT=TARGET -f trick.awk test.txt &lt;BR /&gt;&lt;BR /&gt;second before target 1 (easy)&lt;BR /&gt;first before target 1 (easy)&lt;BR /&gt;first:first TARGET garbage&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;second before target 2 (easy)&lt;BR /&gt;first before target 2 (easy)&lt;BR /&gt;second:second TARGET garbage&lt;BR /&gt;1&lt;BR /&gt;mean:mean TARGET garbage&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;</description>
      <pubDate>Thu, 06 Sep 2001 06:27:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575387#M31077</guid>
      <dc:creator>Volker Borowski</dc:creator>
      <dc:date>2001-09-06T06:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575388#M31078</link>
      <description>Thanks all for your great responses....&lt;BR /&gt;&lt;BR /&gt;Cheers...&lt;BR /&gt;Satish.</description>
      <pubDate>Thu, 06 Sep 2001 10:41:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575388#M31078</guid>
      <dc:creator>Satish Y</dc:creator>
      <dc:date>2001-09-06T10:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575389#M31079</link>
      <description>well done Volker, I was just about to post for the same thing.. &lt;BR /&gt;nice script!&lt;BR /&gt;&lt;BR /&gt;Later,&lt;BR /&gt;Bill</description>
      <pubDate>Fri, 14 Sep 2001 08:32:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/2575389#M31079</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2001-09-14T08:32:38Z</dc:date>
    </item>
  </channel>
</rss>

