<?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 question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925197#M817954</link>
    <description>let x=0&lt;BR /&gt;cat t|while true&lt;BR /&gt;do&lt;BR /&gt;read A B C D&lt;BR /&gt;[ "$A" = "" ] &amp;amp;&amp;amp; exit&lt;BR /&gt;[ "$A" = "sht" ] &amp;amp;&amp;amp; echo $A $B $C $D&lt;BR /&gt;if [ "$A" = "trc" ]&lt;BR /&gt;then&lt;BR /&gt;        let x=$x+1&lt;BR /&gt;        if [ $x -eq 4 ]&lt;BR /&gt;        then&lt;BR /&gt;                echo $A $B $C $D&lt;BR /&gt;                let x=0&lt;BR /&gt;        fi&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;where t (on 2nd line in cat t) is the name of the input file with all your data in.&lt;BR /&gt;</description>
    <pubDate>Wed, 12 Mar 2003 14:41:26 GMT</pubDate>
    <dc:creator>Stefan Farrelly</dc:creator>
    <dc:date>2003-03-12T14:41:26Z</dc:date>
    <item>
      <title>scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925195#M817952</link>
      <description>Hi experts,&lt;BR /&gt;          Im trying to write a script either in awk or in ksh to read in a text file with a format like shown below:&lt;BR /&gt;......start....&lt;BR /&gt;sht 2 3 4&lt;BR /&gt;trc 4 5 5&lt;BR /&gt;trc 3 3 2&lt;BR /&gt;trc 2 3 4&lt;BR /&gt;trc 3 4 1&lt;BR /&gt;trc 1 3 6&lt;BR /&gt;trc 3 3 5&lt;BR /&gt;trc 4 3 1&lt;BR /&gt;trc 2 3 5&lt;BR /&gt;sht 1 6 3&lt;BR /&gt;trc 4 5 5&lt;BR /&gt;trc 3 3 2&lt;BR /&gt;trc 2 3 4&lt;BR /&gt;trc 3 4 1&lt;BR /&gt;trc 1 3 6&lt;BR /&gt;trc 3 3 5&lt;BR /&gt;trc 4 3 1&lt;BR /&gt;trc 2 3 5&lt;BR /&gt;.........end.........&lt;BR /&gt;It is a really long file with similar format. All I want to do is to read in the file and print the line that starts with "sht" and every fourth line that starts with "trc"&lt;BR /&gt;&lt;BR /&gt;Could somebody help me please&lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Mar 2003 14:31:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925195#M817952</guid>
      <dc:creator>soji</dc:creator>
      <dc:date>2003-03-12T14:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925196#M817953</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;awk '/^sht/ || (NR%4 == 0 &amp;amp;&amp;amp; /^trc/){print}' filename&lt;BR /&gt;&lt;BR /&gt;should do the trick (if I interpret the trc requirement correctly).&lt;BR /&gt;&lt;BR /&gt;rgds, Robin</description>
      <pubDate>Wed, 12 Mar 2003 14:36:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925196#M817953</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2003-03-12T14:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925197#M817954</link>
      <description>let x=0&lt;BR /&gt;cat t|while true&lt;BR /&gt;do&lt;BR /&gt;read A B C D&lt;BR /&gt;[ "$A" = "" ] &amp;amp;&amp;amp; exit&lt;BR /&gt;[ "$A" = "sht" ] &amp;amp;&amp;amp; echo $A $B $C $D&lt;BR /&gt;if [ "$A" = "trc" ]&lt;BR /&gt;then&lt;BR /&gt;        let x=$x+1&lt;BR /&gt;        if [ $x -eq 4 ]&lt;BR /&gt;        then&lt;BR /&gt;                echo $A $B $C $D&lt;BR /&gt;                let x=0&lt;BR /&gt;        fi&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;where t (on 2nd line in cat t) is the name of the input file with all your data in.&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Mar 2003 14:41:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925197#M817954</guid>
      <dc:creator>Stefan Farrelly</dc:creator>
      <dc:date>2003-03-12T14:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925198#M817955</link>
      <description>Thanks for the quick reply.&lt;BR /&gt;It is very close. &lt;BR /&gt;&lt;BR /&gt;I actually want to print every fourth occurence of lines begining with "trc"&lt;BR /&gt;&lt;BR /&gt;Thanks a lot again</description>
      <pubDate>Wed, 12 Mar 2003 14:44:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925198#M817955</guid>
      <dc:creator>soji</dc:creator>
      <dc:date>2003-03-12T14:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925199#M817956</link>
      <description>OK, well try:&lt;BR /&gt;&lt;BR /&gt;awk '/^sht/{print}/^trc/{count++;if (count==4){print;count=0}}' file&lt;BR /&gt;&lt;BR /&gt;this resets the counter after 4 occurrences of trc at the beginning of the line.&lt;BR /&gt;&lt;BR /&gt;rgds, Robin</description>
      <pubDate>Wed, 12 Mar 2003 14:47:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925199#M817956</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2003-03-12T14:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925200#M817957</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;file=$1&lt;BR /&gt;typeset -i x=1&lt;BR /&gt;cat $file|while read a b c d&lt;BR /&gt;do&lt;BR /&gt;   case $a in&lt;BR /&gt;   sht) echo $a $b $c $d ;;&lt;BR /&gt;   trc) if [ "$x" -eq "4" ]&lt;BR /&gt;        then&lt;BR /&gt;          let x=1&lt;BR /&gt;          echo $a $b $c $d&lt;BR /&gt;        else&lt;BR /&gt;          typeset -i x=$x+1&lt;BR /&gt;        fi ;;&lt;BR /&gt;   esac&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;             Steve Steel</description>
      <pubDate>Wed, 12 Mar 2003 14:56:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925200#M817957</guid>
      <dc:creator>Steve Steel</dc:creator>
      <dc:date>2003-03-12T14:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925201#M817958</link>
      <description># perl -ne'/^sht/||(/^trc/&amp;amp;&amp;amp;++$t%4==0)and print' log&lt;BR /&gt;sht 2 3 4&lt;BR /&gt;trc 3 4 1&lt;BR /&gt;trc 2 3 5&lt;BR /&gt;sht 1 6 3&lt;BR /&gt;trc 3 4 1&lt;BR /&gt;trc 2 3 5&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy, have FUN! H.Merijn</description>
      <pubDate>Wed, 12 Mar 2003 15:28:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925201#M817958</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-03-12T15:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925202#M817959</link>
      <description>Thank you All for the replies and help...Especially Robin who was quick...I chose you second solution. By the way what does the NR%4 do in your first solution what does modulus do in awk?&lt;BR /&gt;&lt;BR /&gt;thanks</description>
      <pubDate>Fri, 14 Mar 2003 05:31:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925202#M817959</guid>
      <dc:creator>soji</dc:creator>
      <dc:date>2003-03-14T05:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925203#M817960</link>
      <description>hi,&lt;BR /&gt;FYI:&lt;BR /&gt;&lt;BR /&gt;x % y &lt;BR /&gt;Remainder. The quotient is rounded toward zero to an integer, multiplied by y and this result is subtracted from x. This operation is sometimes known as "trunc-mod." The following relation always holds: &lt;BR /&gt;b * int(a / b) + (a % b) == a&lt;BR /&gt;&lt;BR /&gt;One possibly undesirable effect of this definition of remainder is that x % y is negative if x is negative. Thus, &lt;BR /&gt;-17 % 8 = -1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hth&lt;BR /&gt;Yogeeraj</description>
      <pubDate>Fri, 14 Mar 2003 06:09:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2925203#M817960</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2003-03-14T06:09:17Z</dc:date>
    </item>
  </channel>
</rss>

