<?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 needed in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709847#M903923</link>
    <description>Hi Clemens,&lt;BR /&gt;&lt;BR /&gt;Can you put a detailed example that you need?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Justo.</description>
    <pubDate>Wed, 24 Apr 2002 09:32:18 GMT</pubDate>
    <dc:creator>Justo Exposito</dc:creator>
    <dc:date>2002-04-24T09:32:18Z</dc:date>
    <item>
      <title>scripting help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709846#M903922</link>
      <description>Hi all,&lt;BR /&gt;I want to search for a string in an ascii file and the output should include the fifth and the eighth line below the match.&lt;BR /&gt;&lt;BR /&gt;tia&lt;BR /&gt;Clemens</description>
      <pubDate>Wed, 24 Apr 2002 09:22:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709846#M903922</guid>
      <dc:creator>Clemens Kleibusch</dc:creator>
      <dc:date>2002-04-24T09:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709847#M903923</link>
      <description>Hi Clemens,&lt;BR /&gt;&lt;BR /&gt;Can you put a detailed example that you need?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Justo.</description>
      <pubDate>Wed, 24 Apr 2002 09:32:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709847#M903923</guid>
      <dc:creator>Justo Exposito</dc:creator>
      <dc:date>2002-04-24T09:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709848#M903924</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You can try using awk and its getline function.&lt;BR /&gt;Just to give you an idea, lets say you have a file containing:&lt;BR /&gt;111&lt;BR /&gt;222&lt;BR /&gt;333&lt;BR /&gt;444&lt;BR /&gt;555&lt;BR /&gt;666&lt;BR /&gt;777&lt;BR /&gt;888&lt;BR /&gt;999&lt;BR /&gt;000&lt;BR /&gt;&lt;BR /&gt;Try this:&lt;BR /&gt;cat aaa | awk '/111/ {getline; getline; getline; getline; getline x; getline; getline; getline y; print x; print y}'&lt;BR /&gt;&lt;BR /&gt;The output of this is:&lt;BR /&gt;666&lt;BR /&gt;999&lt;BR /&gt;&lt;BR /&gt;You may want to build on this to customise it to your specific requirement.</description>
      <pubDate>Wed, 24 Apr 2002 09:40:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709848#M903924</guid>
      <dc:creator>Deepak Extross</dc:creator>
      <dc:date>2002-04-24T09:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709849#M903925</link>
      <description>See also:&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x83791cc6003bd6118fff0090279cd0f9,00.html" target="_blank"&gt;http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x83791cc6003bd6118fff0090279cd0f9,00.html&lt;/A&gt;</description>
      <pubDate>Wed, 24 Apr 2002 09:50:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709849#M903925</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2002-04-24T09:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709850#M903926</link>
      <description>Hi Deepak,&lt;BR /&gt;thanks for your quick answer. It matches my needs nearly complete.&lt;BR /&gt;Now I need to put this awk command in a loop to change the search string several times.&lt;BR /&gt;So I have to exchange &lt;BR /&gt;cat aaa | awk '/111/  ...  against&lt;BR /&gt;cat aaa | awk '/$xxx/ ...&lt;BR /&gt;But how do I have to quote this variable?&lt;BR /&gt;&lt;BR /&gt;Thanks again&lt;BR /&gt;Clemens</description>
      <pubDate>Wed, 24 Apr 2002 11:17:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709850#M903926</guid>
      <dc:creator>Clemens Kleibusch</dc:creator>
      <dc:date>2002-04-24T11:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709851#M903927</link>
      <description>Hi Clemens,&lt;BR /&gt;&lt;BR /&gt;don't know the syntax for quoting of vars in regular expressions.&lt;BR /&gt;But you can try this:&lt;BR /&gt;cat aaa | awk '{if ($1 ~ YOUR_VAR) {getline; getline; getline; getline; getline x; getline; getline; getline y; print x; print y }}' YOUR_VAR=$PARAM&lt;BR /&gt;or change ($1 ~ YOUR_VAR)&lt;BR /&gt;with ($1 == YOUR_VAR)&lt;BR /&gt;if $PARAM is exactly the row in your input file.&lt;BR /&gt;YOUR_VAR=$PARAM is part of awk command.&lt;BR /&gt;Set your search string to PARAM.&lt;BR /&gt;&lt;BR /&gt;Ruediger&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 24 Apr 2002 12:33:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709851#M903927</guid>
      <dc:creator>Ruediger Noack</dc:creator>
      <dc:date>2002-04-24T12:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709852#M903928</link>
      <description>Hi Clemens,&lt;BR /&gt;&lt;BR /&gt;Consider the following contents of "file":&lt;BR /&gt;a&lt;BR /&gt;b bravo charlie junk&lt;BR /&gt;c charlie delta&lt;BR /&gt;d&lt;BR /&gt;e&lt;BR /&gt;f&lt;BR /&gt;g bravo 5th&lt;BR /&gt;h charlie 5th&lt;BR /&gt;this is it&lt;BR /&gt;1 bravo 8th&lt;BR /&gt;2 charlie 8th&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;5 this one&lt;BR /&gt;6&lt;BR /&gt;7&lt;BR /&gt;8 and this one&lt;BR /&gt;9&lt;BR /&gt;10&lt;BR /&gt;11&lt;BR /&gt;&lt;BR /&gt;Try this script:&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;for var in "this is it" "bravo" "charlie delta"&lt;BR /&gt;do&lt;BR /&gt;awk ''/"$var"/' {getline; getline; getline; getline; getline x; getline; getline&lt;BR /&gt;; getline y; print x; print y}' file&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Note the quoting of the arguments in the for loop.  That enables the embedding of spaces in the search string.&lt;BR /&gt;&lt;BR /&gt;The quoting of $var in the awk statement will preserve the spaces in the search and recognizes the difference between "this is it" (one space between the words) and "this  is  it" (two spaces between the words).&lt;BR /&gt;&lt;BR /&gt;Here's another thing I found in testing.  It may may not apply to your case but just in case it does...&lt;BR /&gt;&lt;BR /&gt;Note that this awk will find multiple references of the search string in the file as long as they are not in the same 8 line block.  For example, search for "charlie" in "file" will return the 5th and 8th lines after the line "b bravo charlie junk", will not return the lines following "c charlie delta", but will return the 5th and 8th following "2 charlie 8th".  That's because the awk statement finds a match, checks the next 8 lines, then begins looking for another match.&lt;BR /&gt;&lt;BR /&gt;Darrell</description>
      <pubDate>Wed, 24 Apr 2002 12:49:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709852#M903928</guid>
      <dc:creator>Darrell Allen</dc:creator>
      <dc:date>2002-04-24T12:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709853#M903929</link>
      <description>Found it..:&lt;BR /&gt;&lt;BR /&gt;awk -v arg=aaa -v pos1=5 -v pos2=9 '{&lt;BR /&gt;   if (count==pos1) print $0&lt;BR /&gt;   if (count==pos2) print $0&lt;BR /&gt;   if (count&amp;gt;=1) count++&lt;BR /&gt;   for (i=1;i&amp;lt;=NR;i++) {&lt;BR /&gt;        if ($i==arg) count=1&lt;BR /&gt;        }&lt;BR /&gt;   } ' &lt;INPUTFILE&gt;&lt;BR /&gt;&lt;BR /&gt;From the inputfile:&lt;BR /&gt;abc&lt;BR /&gt;aaa&lt;BR /&gt;abc1&lt;BR /&gt;abc2&lt;BR /&gt;abc3&lt;BR /&gt;abc4&lt;BR /&gt;abc5&lt;BR /&gt;abc6&lt;BR /&gt;abc7&lt;BR /&gt;abc8&lt;BR /&gt;abc9&lt;BR /&gt;abc10&lt;BR /&gt;abc11&lt;BR /&gt;&lt;BR /&gt;It will give you the result:&lt;BR /&gt;abc5&lt;BR /&gt;abc9&lt;BR /&gt;(it starts counting after retrieval of searchstring "aaa".&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Ceesjan&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/INPUTFILE&gt;</description>
      <pubDate>Wed, 24 Apr 2002 13:35:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709853#M903929</guid>
      <dc:creator>Ceesjan van Hattum</dc:creator>
      <dc:date>2002-04-24T13:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: scripting help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709854#M903930</link>
      <description>Thanks Ruediger,&lt;BR /&gt;your version did what I want it to do.&lt;BR /&gt;Thanks Darrell,&lt;BR /&gt;you teached me the quoting I couldn't work out by myself!&lt;BR /&gt;&lt;BR /&gt;See you&lt;BR /&gt;Clemens</description>
      <pubDate>Wed, 24 Apr 2002 13:38:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help-needed/m-p/2709854#M903930</guid>
      <dc:creator>Clemens Kleibusch</dc:creator>
      <dc:date>2002-04-24T13:38:23Z</dc:date>
    </item>
  </channel>
</rss>

