<?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: Need some AWK help ... in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/need-some-awk-help/m-p/3252803#M887724</link>
    <description>Another Idea coming to my mind:&lt;BR /&gt;&lt;BR /&gt;If the number of records does not vary within a file but you have huge AWKs running on them, it might be easier to keep them as they are, but to modify the input for them so that it is as it was before the update i.e.:&lt;BR /&gt;&lt;BR /&gt;current script:&lt;BR /&gt;awk '&lt;BR /&gt;{&lt;BR /&gt; # huge awk script&lt;BR /&gt; .&lt;BR /&gt; .&lt;BR /&gt;}' filename&lt;BR /&gt;&lt;BR /&gt;future script:&lt;BR /&gt;NF=$(head -1 filename | awk '{print NF}')&lt;BR /&gt;cut -d"," -f1-$((NF-8)),$((NF-6))-$NF filename |&lt;BR /&gt; awk '&lt;BR /&gt;{&lt;BR /&gt;  # same huge awk script as before&lt;BR /&gt;  .&lt;BR /&gt;  .&lt;BR /&gt;}'   # no filename here&lt;BR /&gt;&lt;BR /&gt;could be an even better solution. :)</description>
    <pubDate>Tue, 20 Apr 2004 11:10:15 GMT</pubDate>
    <dc:creator>Juergen Tappe</dc:creator>
    <dc:date>2004-04-20T11:10:15Z</dc:date>
    <item>
      <title>Need some AWK help ...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-some-awk-help/m-p/3252797#M887718</link>
      <description>A new version of the software produced an extra field in it's output log, that is parsed for for reporting.  The new field is not required or wanted to report.  The tool used for parsing is a combination of ksh and awk in a spaghetti-like code monster.  I intend to edit only one of the awk scripts that determines the version of the software used, and insert logic to remove the extra field.  I don't want to introduce any more scripts.  &lt;BR /&gt;&lt;BR /&gt;Since we were able to determine that is only one new field, we would like to remove it, and the following OFS of that field. The FS and OFS is ","  The record could have varying amount fields, but the one we want to remove is always 7th from the last.  &lt;BR /&gt;&lt;BR /&gt;I realize I could just: printf $(NF -7) = "" &lt;BR /&gt;but that still leaves the OFS for the value that was "zero'd" out.&lt;BR /&gt;&lt;BR /&gt;I attached a working test example of what I have right now, and I am hoping someone can tell me an easier way to accomplish this task, and meet the requirements.&lt;BR /&gt;&lt;BR /&gt;TIA !&lt;BR /&gt;</description>
      <pubDate>Mon, 19 Apr 2004 15:12:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-some-awk-help/m-p/3252797#M887718</guid>
      <dc:creator>Robert Gamble</dc:creator>
      <dc:date>2004-04-19T15:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: Need some AWK help ...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-some-awk-help/m-p/3252798#M887719</link>
      <description>I wouldn't bother with OFS and IFS and simply use the split command to load an array using the comma as the separator.&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;  n = split($0,arry,",")&lt;BR /&gt;  if (n &amp;gt; 1)&lt;BR /&gt;    {&lt;BR /&gt;      i = 1&lt;BR /&gt;      while (i &amp;lt; (n - 7))&lt;BR /&gt;        {&lt;BR /&gt;          printf("%s,",arry[i])&lt;BR /&gt;          ++i&lt;BR /&gt;        }&lt;BR /&gt;       ++i;&lt;BR /&gt;       while (i &amp;lt; n)&lt;BR /&gt;         {&lt;BR /&gt;           printf("%s,",arry[i])&lt;BR /&gt;           ++i&lt;BR /&gt;         }&lt;BR /&gt;        printf("%s\n",arry[i])&lt;BR /&gt;      }&lt;BR /&gt;   }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;If I haven't made any typo's that should be your awk script.&lt;BR /&gt;</description>
      <pubDate>Mon, 19 Apr 2004 15:33:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-some-awk-help/m-p/3252798#M887719</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-04-19T15:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Need some AWK help ...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-some-awk-help/m-p/3252799#M887720</link>
      <description>... or you could do it that way :&lt;BR /&gt;&lt;BR /&gt;i=1&lt;BR /&gt;while (i &amp;lt;= NF) &lt;BR /&gt;   {&lt;BR /&gt;     if(i!=(NF-7)) printf "%s,",$i&lt;BR /&gt;     i++&lt;BR /&gt;   }&lt;BR /&gt;print ""&lt;BR /&gt;&lt;BR /&gt;... for each line and NF-7 disarreared.</description>
      <pubDate>Mon, 19 Apr 2004 18:40:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-some-awk-help/m-p/3252799#M887720</guid>
      <dc:creator>Juergen Tappe</dc:creator>
      <dc:date>2004-04-19T18:40:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need some AWK help ...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-some-awk-help/m-p/3252800#M887721</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;To make field number n desappear :&lt;BR /&gt;&lt;BR /&gt;awk '{ $n="" o } { print $0 }' filename&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;Nicolas</description>
      <pubDate>Mon, 19 Apr 2004 20:35:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-some-awk-help/m-p/3252800#M887721</guid>
      <dc:creator>Nicolas Dumeige</dc:creator>
      <dc:date>2004-04-19T20:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: Need some AWK help ...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-some-awk-help/m-p/3252801#M887722</link>
      <description>[continued]&lt;BR /&gt;&lt;BR /&gt;to get rid of the extra blank :&lt;BR /&gt;&lt;BR /&gt;awk '{ ... }' | sed -e 's/\ \//g' &lt;BR /&gt;&lt;BR /&gt;OR&lt;BR /&gt;&lt;BR /&gt;I was wandering how to manage to affect the ascii delete caractere instead of a null string. That way, print would would display a blank, then got backward one caracter.&lt;BR /&gt;&lt;BR /&gt;I use that trick to do a chrono in shell with printf "\\015$ELAPSED "&lt;BR /&gt;&lt;BR /&gt;#-----CHRONO SHELL------------&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;tpssec() {&lt;BR /&gt;H=`date +'%H'` ; M=`date +'%M'` ; S=`date +'%S'`&lt;BR /&gt;echo "($H * 3660) + ($M * 60) + $S" | bc | read DATE&lt;BR /&gt;echo $DATE&lt;BR /&gt;}&lt;BR /&gt;elapsed() {&lt;BR /&gt;DATEREF=$1 ; NEWDATE=$2&lt;BR /&gt;[ $NEWDATE -lt $DATEREF ] &amp;amp;&amp;amp; (( NEWDATE += 87780 ))&lt;BR /&gt;echo "$NEWDATE - $DATEREF" | bc | read DIFF&lt;BR /&gt;if [ $DIFF -ge 3660 ] ; then&lt;BR /&gt;echo "$DIFF / 3660" | bc -l | cut -c1-2 | sed s/"\."// | read HEURE&lt;BR /&gt;echo "$DIFF - ($HEURE * 3660)" | bc | read DIFF&lt;BR /&gt;else&lt;BR /&gt;HEURE=0&lt;BR /&gt;fi&lt;BR /&gt;if [ $DIFF -gt 60 ] ; then&lt;BR /&gt;echo "$DIFF / 60" | bc -l | cut -c1-2 | sed s/"\."// | read MINUTE&lt;BR /&gt;echo "$DIFF - ($MINUTE * 60)" | bc | read DIFF&lt;BR /&gt;else&lt;BR /&gt;MINUTE=0&lt;BR /&gt;fi&lt;BR /&gt;printf "Elapsed time %02d:%02d:%02d" $HEURE $MINUTE $DIFF&lt;BR /&gt;}&lt;BR /&gt;clock() {&lt;BR /&gt;tpssec | read DATEREF&lt;BR /&gt;while : ; do&lt;BR /&gt;tpssec | read NEWDATE&lt;BR /&gt;elapsed $DATEREF $NEWDATE | read ELAPSED&lt;BR /&gt;printf "\\015$ELAPSED "&lt;BR /&gt;sleep 1&lt;BR /&gt;done&lt;BR /&gt;}&lt;BR /&gt;clock&lt;BR /&gt;#-----END OF SHELL------------&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;Nicolas</description>
      <pubDate>Mon, 19 Apr 2004 20:50:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-some-awk-help/m-p/3252801#M887722</guid>
      <dc:creator>Nicolas Dumeige</dc:creator>
      <dc:date>2004-04-19T20:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Need some AWK help ...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-some-awk-help/m-p/3252802#M887723</link>
      <description>Thanks for all the replies!&lt;BR /&gt;&lt;BR /&gt;Special Thanks to Juergen! your example gave me the idea for what I plan to implement. &lt;BR /&gt;&lt;BR /&gt;I have attached an example of my solution.</description>
      <pubDate>Tue, 20 Apr 2004 07:13:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-some-awk-help/m-p/3252802#M887723</guid>
      <dc:creator>Robert Gamble</dc:creator>
      <dc:date>2004-04-20T07:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Need some AWK help ...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-some-awk-help/m-p/3252803#M887724</link>
      <description>Another Idea coming to my mind:&lt;BR /&gt;&lt;BR /&gt;If the number of records does not vary within a file but you have huge AWKs running on them, it might be easier to keep them as they are, but to modify the input for them so that it is as it was before the update i.e.:&lt;BR /&gt;&lt;BR /&gt;current script:&lt;BR /&gt;awk '&lt;BR /&gt;{&lt;BR /&gt; # huge awk script&lt;BR /&gt; .&lt;BR /&gt; .&lt;BR /&gt;}' filename&lt;BR /&gt;&lt;BR /&gt;future script:&lt;BR /&gt;NF=$(head -1 filename | awk '{print NF}')&lt;BR /&gt;cut -d"," -f1-$((NF-8)),$((NF-6))-$NF filename |&lt;BR /&gt; awk '&lt;BR /&gt;{&lt;BR /&gt;  # same huge awk script as before&lt;BR /&gt;  .&lt;BR /&gt;  .&lt;BR /&gt;}'   # no filename here&lt;BR /&gt;&lt;BR /&gt;could be an even better solution. :)</description>
      <pubDate>Tue, 20 Apr 2004 11:10:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-some-awk-help/m-p/3252803#M887724</guid>
      <dc:creator>Juergen Tappe</dc:creator>
      <dc:date>2004-04-20T11:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Need some AWK help ...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-some-awk-help/m-p/3252804#M887725</link>
      <description>The number of fields, and the number of records vary greatly for each file.&lt;BR /&gt;&lt;BR /&gt;The first 23 fields are constant, and the last 15 are constant, with the total number of fields varying between 47 and 72.&lt;BR /&gt;&lt;BR /&gt;Based on a value of the 2nd field, it may remove the $(NF -7).&lt;BR /&gt;&lt;BR /&gt;Thanks again for your assistance!&lt;BR /&gt;&lt;BR /&gt;:)</description>
      <pubDate>Tue, 20 Apr 2004 11:22:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-some-awk-help/m-p/3252804#M887725</guid>
      <dc:creator>Robert Gamble</dc:creator>
      <dc:date>2004-04-20T11:22:02Z</dc:date>
    </item>
  </channel>
</rss>

