<?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/4674337#M658545</link>
    <description>Before I can give a correct answer, I need to know for sure how the data looks like.&lt;BR /&gt;For instance:&lt;BR /&gt;- the 'markers' (aaax, bbbx, cccx, etc.): do they always start with a letter?&lt;BR /&gt;- the 'values': are they always numeric?&lt;BR /&gt;- are there always 3 'values' per 'marker'?&lt;BR /&gt;&lt;BR /&gt;If the answer to the third question is yes, then the answers given above hold. If not, the script needs to be a bit more complicated (it needs to read statefull through the file). I could give an awk script for that, but only if needed.</description>
    <pubDate>Fri, 13 Aug 2010 05:10:39 GMT</pubDate>
    <dc:creator>Elmar P. Kolkman</dc:creator>
    <dc:date>2010-08-13T05:10:39Z</dc:date>
    <item>
      <title>script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674329#M658537</link>
      <description>script&lt;BR /&gt;&lt;BR /&gt;I have the below text file , I would like to extract the data from that , there are many many lines in it , I would like to extract three lines that after the line contains the string "aaa" .  &lt;BR /&gt;&lt;BR /&gt;aaax&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;bbbx&lt;BR /&gt;4&lt;BR /&gt;5&lt;BR /&gt;6&lt;BR /&gt;cccx&lt;BR /&gt;7&lt;BR /&gt;8&lt;BR /&gt;9&lt;BR /&gt;aaax&lt;BR /&gt;10&lt;BR /&gt;11&lt;BR /&gt;12&lt;BR /&gt;dddx&lt;BR /&gt;13&lt;BR /&gt;14&lt;BR /&gt;15&lt;BR /&gt;&lt;BR /&gt;The result that I would like to have is as below .&lt;BR /&gt;&lt;BR /&gt;aaax&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;aaax&lt;BR /&gt;10&lt;BR /&gt;11&lt;BR /&gt;12&lt;BR /&gt;&lt;BR /&gt;Can advise what can i do ? thx</description>
      <pubDate>Fri, 13 Aug 2010 01:40:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674329#M658537</guid>
      <dc:creator>ivy1234</dc:creator>
      <dc:date>2010-08-13T01:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674330#M658538</link>
      <description>$ awk 'ORS=NR%4?FS:RS' file|awk /^aaa/| tr " " "\n"&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 13 Aug 2010 02:21:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674330#M658538</guid>
      <dc:creator>Raj D.</dc:creator>
      <dc:date>2010-08-13T02:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674331#M658539</link>
      <description>thx reply,&lt;BR /&gt;&lt;BR /&gt;When use the script to run my file , it pops the error , besides , if I want the line contains aaa not begins aaa , what can i do ? thx&lt;BR /&gt;&lt;BR /&gt;tr: two strings must be given when translating&lt;BR /&gt;cat: awk: No such file or directory&lt;BR /&gt;cat: ORS=NR%4?FS:RS: No such file or directory&lt;BR /&gt;</description>
      <pubDate>Fri, 13 Aug 2010 02:55:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674331#M658539</guid>
      <dc:creator>ivy1234</dc:creator>
      <dc:date>2010-08-13T02:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674332#M658540</link>
      <description>lby1234,&lt;BR /&gt;&lt;BR /&gt;- See the example below: &lt;BR /&gt;- expecting the file to be uniform of , matching pattern aaa then 3 line with numbers . &lt;BR /&gt;- There must be some other way with perl as well or sed. &lt;BR /&gt;&lt;BR /&gt;$ cat file&lt;BR /&gt;aaax&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;bbbx&lt;BR /&gt;4&lt;BR /&gt;5&lt;BR /&gt;6&lt;BR /&gt;cccx&lt;BR /&gt;7&lt;BR /&gt;8&lt;BR /&gt;9&lt;BR /&gt;aaax&lt;BR /&gt;10&lt;BR /&gt;11&lt;BR /&gt;12&lt;BR /&gt;dddx&lt;BR /&gt;13&lt;BR /&gt;14&lt;BR /&gt;15&lt;BR /&gt;ZZaaax&lt;BR /&gt;101&lt;BR /&gt;112&lt;BR /&gt;123&lt;BR /&gt;YYdddx&lt;BR /&gt;134&lt;BR /&gt;145&lt;BR /&gt;156&lt;BR /&gt;$&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$ cat -n file&lt;BR /&gt;     1  aaax&lt;BR /&gt;     2  1&lt;BR /&gt;     3  2&lt;BR /&gt;     4  3&lt;BR /&gt;     5  bbbx&lt;BR /&gt;     6  4&lt;BR /&gt;     7  5&lt;BR /&gt;     8  6&lt;BR /&gt;     9  cccx&lt;BR /&gt;    10  7&lt;BR /&gt;    11  8&lt;BR /&gt;    12  9&lt;BR /&gt;    13  aaax&lt;BR /&gt;    14  10&lt;BR /&gt;    15  11&lt;BR /&gt;    16  12&lt;BR /&gt;    17  dddx&lt;BR /&gt;    18  13&lt;BR /&gt;    19  14&lt;BR /&gt;    20  15&lt;BR /&gt;    21  ZZaaax&lt;BR /&gt;    22  101&lt;BR /&gt;    23  112&lt;BR /&gt;    24  123&lt;BR /&gt;    25  YYdddx&lt;BR /&gt;    26  134&lt;BR /&gt;    27  145&lt;BR /&gt;    28  156&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;## Here is the result: (all mathcing with aaa ) &lt;BR /&gt;#----------------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$ awk 'ORS=NR%4?FS:RS' file|awk /aaa/|tr " " "\n"&lt;BR /&gt;aaax&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;aaax&lt;BR /&gt;10&lt;BR /&gt;11&lt;BR /&gt;12&lt;BR /&gt;ZZaaax&lt;BR /&gt;101&lt;BR /&gt;112&lt;BR /&gt;123&lt;BR /&gt;$&lt;BR /&gt;&lt;BR /&gt;#--------------------------------------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# make sure os and awk/tr are correct: &lt;BR /&gt;$ uname -a ; which awk ; which tr&lt;BR /&gt;HP-UX hpux1120 B.11.23 U 9000/800 765567890 unlimited-user &lt;BR /&gt;/usr/bin/awk&lt;BR /&gt;/usr/bin/tr&lt;BR /&gt;$&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hth,&lt;BR /&gt;Raj.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;* You have assigned to 6 out of 40 responses only.  ???</description>
      <pubDate>Fri, 13 Aug 2010 03:13:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674332#M658540</guid>
      <dc:creator>Raj D.</dc:creator>
      <dc:date>2010-08-13T03:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674333#M658541</link>
      <description>ivy,&lt;BR /&gt;&lt;BR /&gt;Check this out, this  is much easier with sed:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# sed -n '/aaa/{N;N;N;p;}' file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have fun,&lt;BR /&gt;Raj.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;* Remember to assign points once done.&lt;BR /&gt;</description>
      <pubDate>Fri, 13 Aug 2010 03:30:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674333#M658541</guid>
      <dc:creator>Raj D.</dc:creator>
      <dc:date>2010-08-13T03:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674334#M658542</link>
      <description>ivy,&lt;BR /&gt;See below the example: with sed : &lt;BR /&gt;This is good and simple to find the pattern and print next desired lines, &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$ cat file&lt;BR /&gt;aaax&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;bbbx&lt;BR /&gt;4&lt;BR /&gt;5&lt;BR /&gt;6&lt;BR /&gt;cccx&lt;BR /&gt;7&lt;BR /&gt;8&lt;BR /&gt;9&lt;BR /&gt;aaax&lt;BR /&gt;10&lt;BR /&gt;11&lt;BR /&gt;12&lt;BR /&gt;dddx&lt;BR /&gt;13&lt;BR /&gt;14&lt;BR /&gt;15&lt;BR /&gt;ZZaaax&lt;BR /&gt;101&lt;BR /&gt;112&lt;BR /&gt;123&lt;BR /&gt;YYdddx&lt;BR /&gt;134&lt;BR /&gt;145&lt;BR /&gt;156&lt;BR /&gt;$&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$ sed -n '/aaa/{N;N;N;p;}' file&lt;BR /&gt;aaax&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;aaax&lt;BR /&gt;10&lt;BR /&gt;11&lt;BR /&gt;12&lt;BR /&gt;ZZaaax&lt;BR /&gt;101&lt;BR /&gt;112&lt;BR /&gt;123&lt;BR /&gt;$&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy,&lt;BR /&gt;Raj.</description>
      <pubDate>Fri, 13 Aug 2010 03:32:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674334#M658542</guid>
      <dc:creator>Raj D.</dc:creator>
      <dc:date>2010-08-13T03:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674335#M658543</link>
      <description>&lt;!--!*#--&gt;awk '&lt;BR /&gt;/aaa/ {&lt;BR /&gt;   print $0&lt;BR /&gt;   getline; print $0 # next 3 lines&lt;BR /&gt;   getline; print $0&lt;BR /&gt;   getline; print $0&lt;BR /&gt;}' file&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Raj D.: this is much easier with sed:&lt;BR /&gt;&lt;BR /&gt;But sed is likely to be harder to understand.</description>
      <pubDate>Fri, 13 Aug 2010 04:11:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674335#M658543</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-08-13T04:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674336#M658544</link>
      <description>If you want something even easier, use GNU grep:&lt;BR /&gt;grep -A3 aaa file | grep -v "^--$"&lt;BR /&gt;&lt;BR /&gt;You need the second grep to get rid of the separator lines.</description>
      <pubDate>Fri, 13 Aug 2010 04:17:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674336#M658544</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-08-13T04:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674337#M658545</link>
      <description>Before I can give a correct answer, I need to know for sure how the data looks like.&lt;BR /&gt;For instance:&lt;BR /&gt;- the 'markers' (aaax, bbbx, cccx, etc.): do they always start with a letter?&lt;BR /&gt;- the 'values': are they always numeric?&lt;BR /&gt;- are there always 3 'values' per 'marker'?&lt;BR /&gt;&lt;BR /&gt;If the answer to the third question is yes, then the answers given above hold. If not, the script needs to be a bit more complicated (it needs to read statefull through the file). I could give an awk script for that, but only if needed.</description>
      <pubDate>Fri, 13 Aug 2010 05:10:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674337#M658545</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2010-08-13T05:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674338#M658546</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Another way:&lt;BR /&gt;&lt;BR /&gt;# perl -ne '{if (m/aaa/) {$i=3};$i--&amp;gt;=0 and print}' file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 13 Aug 2010 12:11:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4674338#M658546</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-08-13T12:11:30Z</dc:date>
    </item>
  </channel>
</rss>

