<?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: awk help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920050#M817293</link>
    <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;Thanks a mill. Found the Solution.&lt;BR /&gt;&lt;BR /&gt;Chris</description>
    <pubDate>Thu, 06 Mar 2003 19:47:29 GMT</pubDate>
    <dc:creator>Chris Frangandonis</dc:creator>
    <dc:date>2003-03-06T19:47:29Z</dc:date>
    <item>
      <title>awk help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920040#M817283</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;Is there a way that I can print $2 $4 $6 ...etc&lt;BR /&gt;if field $2 is -eq 2 &amp;amp;&amp;amp; $6 = 6 then print $2 $4 $8. &lt;BR /&gt;eg&lt;BR /&gt;cat file | awk {if($2~/[2,3,5]1){print  $0}} , will result in&lt;BR /&gt;&lt;BR /&gt;BIL=84 3500 0c0000 31 49 1172850950   P=64 03030500251a 40 201c00 P=65 07 28505000         P=6e 06 4a54d53d P&lt;BR /&gt;=67 110000 P=7a 0100 P=6c 5244474c4142 0600 1b&lt;BR /&gt;BIL=84 3f00 0c0000 31 49 1148940550   P=64 03030500252e 40 201c00 P=65 0a 0124839026       P=8e 05 030000 P=6&lt;BR /&gt;e 06 6e39412a P=67 6f0000 P=7a 0200 P=6c 4a474d484142 0800 07 P=66 04 00 00&lt;BR /&gt;BIL=84 3f00 0c0000 31 49 1148940030   P=64 030305002536 40 201c00 P=65 0a 0124839028       P=8e 05 030000 P=6&lt;BR /&gt;e 06 8a64a712 P=67 6e0000 P=7a 0200 P=6c 4a4446484142 2f00 1c P=66 04 00 00&lt;BR /&gt;BIL=84 3b00 0c0000 51 49 1148307170   P=64 030305002609 40 160d00 P=65 0a 0860007249       P=82 05 1000 00 P=&lt;BR /&gt;6e 06 4ad2db3d P=67 080000 P=7a 0100 P=6c 4842574c4142 0900 1d&lt;BR /&gt;&lt;BR /&gt;What I want to achieve is to print only the fields that I request for eg&lt;BR /&gt;1172850950  03030500251a    28505000  201c00 4a54d53d&lt;BR /&gt;1148940550  03030500252e  0124839026  201c00 6e39412a &lt;BR /&gt;???etc&lt;BR /&gt;&lt;BR /&gt;Many Thanks&lt;BR /&gt;Chris&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Mar 2003 18:14:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920040#M817283</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2003-03-05T18:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: awk help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920041#M817284</link>
      <description>awk ' $2 == 2 &amp;amp;&amp;amp; $6 == 6 {print $2, $4, $8}' file</description>
      <pubDate>Wed, 05 Mar 2003 18:21:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920041#M817284</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2003-03-05T18:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: awk help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920042#M817285</link>
      <description>After see the example ...&lt;BR /&gt;&lt;BR /&gt;awk use $2 too to field #2 and $6 to field #6&lt;BR /&gt;&lt;BR /&gt;so you like to something like:&lt;BR /&gt;&lt;BR /&gt;awk ' $2 == sh_var2 &amp;amp;&amp;amp; $6 == sh_var6 { print $2 $4 $8 }' sh_var2=$2 sh_var6=$6 file &lt;BR /&gt;&lt;BR /&gt;??????&lt;BR /&gt;&lt;BR /&gt;Put a example of your file, values for search and output expected.</description>
      <pubDate>Wed, 05 Mar 2003 18:33:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920042#M817285</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2003-03-05T18:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: awk help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920043#M817286</link>
      <description>Hi Carlos,&lt;BR /&gt;&lt;BR /&gt;Thanks. If you look at  the file after I printed it you will see that "1172850950" is $6&lt;BR /&gt; and 03030500251a is $8, 28505000 is $13,"201c00" is $10 and this is were my problem lays is the next $variable. It is sometimes at $16, $19 and $20 ..etc, (common is "P=6e")&lt;BR /&gt;&lt;BR /&gt;Thanks Once again&lt;BR /&gt;Chris</description>
      <pubDate>Wed, 05 Mar 2003 18:33:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920043#M817286</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2003-03-05T18:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: awk help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920044#M817287</link>
      <description>I cant understand (yet).&lt;BR /&gt;&lt;BR /&gt;Maybe you need to use NF variable or/and for&lt;BR /&gt;&lt;BR /&gt;awk '{ print NF , $NF , $(NF-3) }' file &lt;BR /&gt;&lt;BR /&gt;will print #fields last field (last_field)-3&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;you can write something like&lt;BR /&gt;&lt;BR /&gt;{ for ( f=20; f&lt;NF&gt;&lt;/NF&gt;&lt;BR /&gt;    ( if == "P=6e" ) print $(f+1)&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Good luck.&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Mar 2003 18:49:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920044#M817287</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2003-03-05T18:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: awk help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920045#M817288</link>
      <description>Hi Carlos,&lt;BR /&gt;&lt;BR /&gt;My Output file looks like this :&lt;BR /&gt;&lt;BR /&gt;BIL=84 3500 0c0000 31 49 1172850950 P=64 03030500251a 40 201c00 P=65 07 28505000 P=6e 06 4a54d53d P=67 110000 P=7a 0100 P=6c 5244474c4142 0600 1b &lt;BR /&gt;&lt;BR /&gt;BIL=84 3f00 0c0000 31 49 1148940550 P=64 03030500252e 40 201c00 P=65 0a 0124839026 P=8e 05 030000 P=6e 06 6e39412a P=67 6f0000 P=7a 0200 P=6c 4a474d484142 0800 07 P=66 04 00 00 &lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;From the above example, my Output must look like this:&lt;BR /&gt;&lt;BR /&gt;1172850950 03030500251a 28505000 201c00 4a54d53d &lt;BR /&gt;1148940550 03030500252e 0124839026 201c00 6e39412a &lt;BR /&gt;&lt;BR /&gt;Hope this is of help&lt;BR /&gt;&lt;BR /&gt;Chris&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Mar 2003 19:04:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920045#M817288</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2003-03-05T19:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: awk help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920046#M817289</link>
      <description>Trying to understand:&lt;BR /&gt;&lt;BR /&gt;BIL= $8 ... P=64 print_this ... P=6e print_this_also ...&lt;BR /&gt;&lt;BR /&gt;So from each line starting with "BIL=" you want to print field #8 and the field following the token "P=64" and the field following the token "P=6e" &lt;BR /&gt;&lt;BR /&gt;And you can not predict, if in the ... spaces are zero or more other tokens in between ?&lt;BR /&gt;&lt;BR /&gt;Is the sequence of P=64 and P=6e predictable, or can P=6e be switched with P=64 ?&lt;BR /&gt;&lt;BR /&gt;Volker</description>
      <pubDate>Wed, 05 Mar 2003 19:21:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920046#M817289</guid>
      <dc:creator>Volker Borowski</dc:creator>
      <dc:date>2003-03-05T19:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: awk help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920047#M817290</link>
      <description>Hi Vol&lt;BR /&gt;&lt;BR /&gt;Yes the record starts at BIL=84 and yes I want to print #6 ,#8 ,#13, #10 , which are aligned which is no problem, but when it comes to "P=6e" ,it is sometimes at #16 or #19 or #20 depending on the bytes before P=6e &lt;BR /&gt;for example&lt;BR /&gt;&lt;BR /&gt;BIL=84 .. .. .. .. . P=65 0a 0124839028 P=8e 05 030000 P=6e 06 8a64a712 ( &amp;lt;---this is #19)&lt;BR /&gt;BIL=84 .. ... ... .. P=65 0a 0860007249 P=82 05 1000 00 P=6e 06 4ad2db3d (&amp;lt;---this is #20)&lt;BR /&gt;and &lt;BR /&gt;BIL=84 .. .. .. .. .  P=64 03030500251a 40 201c00 P=65 07 28505000 P=6e 06 4a54d53d (&amp;lt;---this is  #16)&lt;BR /&gt;&lt;BR /&gt;Does this help&lt;BR /&gt;&lt;BR /&gt;Chris&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Mar 2003 19:48:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920047#M817290</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2003-03-05T19:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: awk help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920048#M817291</link>
      <description>It looks like the values you are looking for are relative to the P= values. Here is a one line perl command to generate the results-&lt;BR /&gt;&lt;BR /&gt;perl -n -e 'chomp; /^BIL=(\S+\s+){5,5}(\S+)/ &amp;amp;&amp;amp; do {$a1=$2};/P=64 (\S+)\s+\S+\s+(\S+)/ &amp;amp;&amp;amp; do {$a2=$1;$a4=$2};/P=65 \S+\s+(\S+)/ &amp;amp;&amp;amp; d&lt;BR /&gt;o {$a3=$1};/P=6e \S+\s+(\S+)/ &amp;amp;&amp;amp; do {$a5=$1};print join(" ",$a1,$a2,$a3,$a4,$a5),"\n";' yourfile&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Mar 2003 22:20:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920048#M817291</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-03-05T22:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: awk help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920049#M817292</link>
      <description>Hi Chris,&lt;BR /&gt;&lt;BR /&gt;A combination of shell and awk. This will print the output in the format you wanted, except for the 10th and 13th field. Once the output is generated, you can easily use another simpl e awk statement to put them  in order. Modify the DATA variable with your file&lt;BR /&gt;&lt;BR /&gt;//&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;DATA=data&lt;BR /&gt;grep "^BIL" $DATA |while read line                                  &lt;BR /&gt;do                                                                 &lt;BR /&gt;echo $line |awk '                                                  &lt;BR /&gt;            {                                                      &lt;BR /&gt;            if ( $0 ~ "^BIL" )                                     &lt;BR /&gt;{                                                                  &lt;BR /&gt;        for (e=1; e &amp;lt;= NF; e++)                                    &lt;BR /&gt;        {                                                          &lt;BR /&gt;            if ( $e ~ "P\=6e" ) {                                  &lt;BR /&gt;            printf ("%s ", $(e+2))                                 &lt;BR /&gt;            exit }                                                 &lt;BR /&gt;            else                                                   &lt;BR /&gt;            {                                                      &lt;BR /&gt;            if ( e == 6 || e == 8 || e == 10 || e == 13  )  {      &lt;BR /&gt;            printf ("%s ", $e)}                                    &lt;BR /&gt;            }                                                      &lt;BR /&gt;                                                                   &lt;BR /&gt;            }                                                      &lt;BR /&gt;}                                                                  &lt;BR /&gt;            }'                                                     &lt;BR /&gt;            printf "\n"                                            &lt;BR /&gt;                                                                   &lt;BR /&gt;            done                                                   &lt;BR /&gt;//&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 05 Mar 2003 23:21:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920049#M817292</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2003-03-05T23:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: awk help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920050#M817293</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;Thanks a mill. Found the Solution.&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Thu, 06 Mar 2003 19:47:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help/m-p/2920050#M817293</guid>
      <dc:creator>Chris Frangandonis</dc:creator>
      <dc:date>2003-03-06T19:47:29Z</dc:date>
    </item>
  </channel>
</rss>

