<?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: Another scripting problem in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820516#M940102</link>
    <description># perl -ne '/^=+ Currently Bad/ .. /^$/ and print'</description>
    <pubDate>Tue, 08 Oct 2002 04:29:58 GMT</pubDate>
    <dc:creator>H.Merijn Brand (procura</dc:creator>
    <dc:date>2002-10-08T04:29:58Z</dc:date>
    <item>
      <title>Another scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820509#M940095</link>
      <description>Hi!&lt;BR /&gt;This could be a simple problem to you but very complex for me :)&lt;BR /&gt;I need to write a script that will grep the content of a program which looks something like this.&lt;BR /&gt;&lt;BR /&gt;pm_9769625.log for details&lt;BR /&gt;Wed Oct  2 08:44:17 2002 #9769695# Route status has changed to bad: arc-id=1, Me&lt;BR /&gt;ssage:administrative route = APM_X25_BRICKFIELD_U2_SPONT1_CONCHECK See APM log c&lt;BR /&gt;6xapm_9769625.log for details&lt;BR /&gt;Wed Oct  2 09:28:18 2002 #9769695# Route status has changed to ok: arc-id=1, Mes&lt;BR /&gt;sage:administrative route = APM_X25_BRICKFIELD_U2_SPONT1_CONCHECK See APM log c6&lt;BR /&gt;xapm_9769625.log for details&lt;BR /&gt;&lt;BR /&gt;============================ Currently Bad Routes ==============================&lt;BR /&gt;&lt;BR /&gt;Sun Oct  6 16:46:32 2002 #9769641# Route status has changed to bad: arc-id=1, Me&lt;BR /&gt;ssage:administrative route = APM_X25_YONG_PENG_SPONT1_CONCHECK See APM log c6xap&lt;BR /&gt;m_9769625.log for details&lt;BR /&gt;&lt;BR /&gt;How can I grep only the lines after the line "============================ Currently Bad Routes ==============================&lt;BR /&gt;"?&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2002 03:53:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820509#M940095</guid>
      <dc:creator>Aminur Rizal</dc:creator>
      <dc:date>2002-10-08T03:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: Another scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820510#M940096</link>
      <description>put everything in file.&lt;BR /&gt;&lt;BR /&gt;sed '/----,$/p' your_file_name</description>
      <pubDate>Tue, 08 Oct 2002 04:09:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820510#M940096</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2002-10-08T04:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Another scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820511#M940097</link>
      <description>Anil, it doesnt work .</description>
      <pubDate>Tue, 08 Oct 2002 04:17:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820511#M940097</guid>
      <dc:creator>Aminur Rizal</dc:creator>
      <dc:date>2002-10-08T04:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Another scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820512#M940098</link>
      <description>Hi &lt;BR /&gt;&lt;BR /&gt;In awk it's like this&lt;BR /&gt;&lt;BR /&gt;awk '{line[NR]=$0; &lt;BR /&gt;      if ( line[NR] ~ /====== Currently Bad Routes ====/ ) &lt;BR /&gt;      border=NR}&lt;BR /&gt;    END &lt;BR /&gt;     {for (i=border+1;i&amp;lt;=NR;i++) print line[i]&lt;BR /&gt;     }&lt;BR /&gt;   ' filename &lt;BR /&gt;&lt;BR /&gt;Short explanation:&lt;BR /&gt;you read the whole file:&lt;BR /&gt;line[NR]=$0&lt;BR /&gt;remember the line number with the searchpattern&lt;BR /&gt;if ( line[NR] ~ /====== Currently Bad Routes ====/ ) &lt;BR /&gt;      border=NR}&lt;BR /&gt;and only shows the file from this line to the end&lt;BR /&gt;for (i=border+1;i&amp;lt;=NR;i++) print line[i]&lt;BR /&gt;&lt;BR /&gt;Chris&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2002 04:20:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820512#M940098</guid>
      <dc:creator>Christian Gebhardt</dc:creator>
      <dc:date>2002-10-08T04:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: Another scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820513#M940099</link>
      <description># perl -ne '/^=+ Currently Bad/ .. /^$/ and print'</description>
      <pubDate>Tue, 08 Oct 2002 04:26:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820513#M940099</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-10-08T04:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: Another scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820514#M940100</link>
      <description>Aminur: interesting problem.&lt;BR /&gt;&lt;BR /&gt;As in all unix scripts, there are no doubt a dozen ways to do this, six of which are acceptable, and a couple of which are ideal.&lt;BR /&gt;&lt;BR /&gt;I think I would start by using a combination of 'wc -l' to determine how many lines total are in the file, and keeping that in a variable.  &lt;BR /&gt;&lt;BR /&gt;Then, with 'grep -n ...', grep for the '== Currently Bad Routes ==' string, which would give you the line number for that line.  You could create a variable that was the difference between that line and the last line, call it, say, DIFF.  &lt;BR /&gt;&lt;BR /&gt;Then, I would use 'tail -$DIFF' on the file, and pipe it to 'grep', which would let you search for whatever you want to match, in just the lines following the "Current Bad Routes" string.&lt;BR /&gt;&lt;BR /&gt;Very possibly, this could all be done in one massive command line, but it would be much simpler to do it as several lines in a script.&lt;BR /&gt;&lt;BR /&gt;I have no machine to hack up a workable version just now, so I'll have to leave it at this, aside from suggesting that the use of 'sed', 'awk', or 'ed' can probably make short work of this, but I have not mastered them enough to suggest exactly how.  Then there's perl...&lt;BR /&gt;&lt;BR /&gt;Anyway, I hope these ideas are enough to get you started.  Hopefully, they are somewhere in the top six, not the bottom six, of the dozen workable suggestions.&lt;BR /&gt;&lt;BR /&gt;Regards, --bmr</description>
      <pubDate>Tue, 08 Oct 2002 04:28:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820514#M940100</guid>
      <dc:creator>Brian M Rawlings</dc:creator>
      <dc:date>2002-10-08T04:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: Another scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820515#M940101</link>
      <description>Aminur: interesting problem.&lt;BR /&gt;&lt;BR /&gt;As in all unix scripts, there are no doubt a dozen ways to do this, six of which are acceptable, and a couple of which are ideal.&lt;BR /&gt;&lt;BR /&gt;I think I would start by using a combination of 'wc -l' to determine how many lines total are in the file, and keeping that in a variable.  &lt;BR /&gt;&lt;BR /&gt;Then, with 'grep -n ...', grep for the '== Currently Bad Routes ==' string, which would give you the line number for that line.  You could create a variable that was the difference between that line and the last line, call it, say, DIFF.  &lt;BR /&gt;&lt;BR /&gt;Then, I would use 'tail -$DIFF' on the file, and pipe it to 'grep', which would let you search for whatever you want to match, in just the lines following the "Current Bad Routes" string.&lt;BR /&gt;&lt;BR /&gt;Very possibly, this could all be done in one massive command line, but it would be much simpler to do it as several lines in a script.&lt;BR /&gt;&lt;BR /&gt;I have no machine to hack up a workable version just now, so I'll have to leave it at this, aside from suggesting that the use of 'sed', 'awk', or 'ed' can probably make short work of this, but I have not mastered them enough to suggest exactly how.  Then there's perl...&lt;BR /&gt;&lt;BR /&gt;Anyway, I hope these ideas are enough to get you started.  Hopefully, they are somewhere in the top six, not the bottom six, of the dozen workable suggestions.&lt;BR /&gt;&lt;BR /&gt;Regards, --bmr</description>
      <pubDate>Tue, 08 Oct 2002 04:29:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820515#M940101</guid>
      <dc:creator>Brian M Rawlings</dc:creator>
      <dc:date>2002-10-08T04:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: Another scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820516#M940102</link>
      <description># perl -ne '/^=+ Currently Bad/ .. /^$/ and print'</description>
      <pubDate>Tue, 08 Oct 2002 04:29:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820516#M940102</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-10-08T04:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: Another scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820517#M940103</link>
      <description>Chris,&lt;BR /&gt;I got the following error:-&lt;BR /&gt;&lt;BR /&gt;syntax error The source line is 5.&lt;BR /&gt; The error context is&lt;BR /&gt;                END &amp;gt;&amp;gt;&amp;gt; &lt;BR /&gt; &amp;lt;&amp;lt;&amp;lt; &lt;BR /&gt; awk: Quitting&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2002 04:30:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820517#M940103</guid>
      <dc:creator>Aminur Rizal</dc:creator>
      <dc:date>2002-10-08T04:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Another scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820518#M940104</link>
      <description>Aminur: interesting problem.&lt;BR /&gt;&lt;BR /&gt;As in all unix scripts, there are no doubt a dozen ways to do this, six of which are acceptable, and a couple of which are ideal.&lt;BR /&gt;&lt;BR /&gt;I think I would start by using a combination of 'wc -l' to determine how many lines total are in the file, and keeping that in a variable.  &lt;BR /&gt;&lt;BR /&gt;Then, with 'grep -n ...', grep for the '== Currently Bad Routes ==' string, which would give you the line number for that line.  You could create a variable that was the difference between that line and the last line, call it, say, DIFF.  &lt;BR /&gt;&lt;BR /&gt;Then, I would use 'tail -$DIFF' on the file, and pipe it to 'grep', which would let you search for whatever you want to match, in just the lines following the "Current Bad Routes" string.&lt;BR /&gt;&lt;BR /&gt;Very possibly, this could all be done in one massive command line, but it would be much simpler to do it as several lines in a script.&lt;BR /&gt;&lt;BR /&gt;I have no machine to hack up a workable version just now, so I'll have to leave it at this, aside from suggesting that the use of 'sed', 'awk', or 'ed' can probably make short work of this, but I have not mastered them enough to suggest exactly how.  Then there's perl...&lt;BR /&gt;&lt;BR /&gt;Anyway, I hope these ideas are enough to get you started.  Hopefully, they are somewhere in the top six, not the bottom six, of the dozen workable suggestions.&lt;BR /&gt;&lt;BR /&gt;Regards, --bmr</description>
      <pubDate>Tue, 08 Oct 2002 04:34:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820518#M940104</guid>
      <dc:creator>Brian M Rawlings</dc:creator>
      <dc:date>2002-10-08T04:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: Another scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820519#M940105</link>
      <description>Holy Cow!&lt;BR /&gt;&lt;BR /&gt;Well, between procura and I, we've used up a drive on the HP web site...  Sorry about this, I expect we had the same problem of 'submit' hanging (try again, repeat as necessary...)&lt;BR /&gt;&lt;BR /&gt;If an HP person happens by, maybe they can clean this one up a little.&lt;BR /&gt;&lt;BR /&gt;Oh well, what's a 73GB drive among friends?&lt;BR /&gt;&lt;BR /&gt;8^)</description>
      <pubDate>Tue, 08 Oct 2002 04:39:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820519#M940105</guid>
      <dc:creator>Brian M Rawlings</dc:creator>
      <dc:date>2002-10-08T04:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: Another scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820520#M940106</link>
      <description>Brian, I already reported that to Dan.&lt;BR /&gt;Aminur, sorry :)</description>
      <pubDate>Tue, 08 Oct 2002 04:44:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820520#M940106</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-10-08T04:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: Another scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820521#M940107</link>
      <description>procura,&lt;BR /&gt;It doesnt work for me .&lt;BR /&gt;&lt;BR /&gt;Brian,&lt;BR /&gt;I agree with your suggestion&lt;BR /&gt;For your info the lines are actually output from a troubleshooting script which actually varies with time depends on the errors .&lt;BR /&gt;Meant that it is impossible for me to get the number of lines, as it varies.&lt;BR /&gt;&lt;BR /&gt;Still haven't find the right solutions :(&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2002 04:46:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820521#M940107</guid>
      <dc:creator>Aminur Rizal</dc:creator>
      <dc:date>2002-10-08T04:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Another scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820522#M940108</link>
      <description>ok. that's a copy and paste problem:&lt;BR /&gt;&lt;BR /&gt;try this:&lt;BR /&gt;&lt;BR /&gt;awk '{line[NR]=$0;&lt;BR /&gt;if ( line[NR] ~ /====== Currently Bad Routes ====/ )&lt;BR /&gt;border=NR}&lt;BR /&gt;END {&lt;BR /&gt;for (i=border+1;i&amp;lt;=NR;i++) print line[i]&lt;BR /&gt;}&lt;BR /&gt;' filename&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Tue, 08 Oct 2002 05:15:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820522#M940108</guid>
      <dc:creator>Christian Gebhardt</dc:creator>
      <dc:date>2002-10-08T05:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: Another scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820523#M940109</link>
      <description>Chris,&lt;BR /&gt;Great!!!&lt;BR /&gt;It really works this time.&lt;BR /&gt;&lt;BR /&gt;Thanks all, especially for Chris.&lt;BR /&gt;You really make my day!</description>
      <pubDate>Tue, 08 Oct 2002 05:34:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820523#M940109</guid>
      <dc:creator>Aminur Rizal</dc:creator>
      <dc:date>2002-10-08T05:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Another scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820524#M940110</link>
      <description>Glad that the awk thingy works for you, but just out of curiousity, why does the uttermost simple perl solution not work for you? Still using perl4 from /usr/contrib/bin?</description>
      <pubDate>Tue, 08 Oct 2002 07:11:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820524#M940110</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-10-08T07:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: Another scripting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820525#M940111</link>
      <description>Sed could do it too.  Remember sed?  Awk's brother?&lt;BR /&gt;&lt;BR /&gt;ANOTHER WAY:&lt;BR /&gt;START=`grep -E -n "== Currently Bad Routes =="  yourfile | awk -F: '// {print $1}' `&lt;BR /&gt;cat yourfile | sed -n "$START,$p" &amp;gt; your_smaller_file.&lt;BR /&gt;&lt;BR /&gt;another way explained:&lt;BR /&gt;Let's say the line you want is line 345. &lt;BR /&gt;grep -E -n "== Currently Bad Routes =="  yourfile &lt;BR /&gt;Returns    345: == Currently Bad Routes ==&lt;BR /&gt;The  awk -F: '// {print $1}'  gives you the first number (345).&lt;BR /&gt;&lt;BR /&gt;sed -n '345,$p'  Says to print only from line 345 to the end (aka $) of the file.&lt;BR /&gt;But we use double quotes to interpolate the variable. So&lt;BR /&gt;sed -n "$START,$p" becomes   sed -n "345,$p"&lt;BR /&gt;&lt;BR /&gt;FYI:  I had a problem in the past where the size of the file was so big, I exceeded the ability for tail to get all of the information.  Or it was a limit through the pipe "|"?  I just remembered that large files had some bizare effects.</description>
      <pubDate>Wed, 09 Oct 2002 11:23:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-scripting-problem/m-p/2820525#M940111</guid>
      <dc:creator>Steve Post</dc:creator>
      <dc:date>2002-10-09T11:23:48Z</dc:date>
    </item>
  </channel>
</rss>

