<?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: Help with AWK script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900920#M104844</link>
    <description>If you do go the "perl" route, then I recommend reading the acct records directly.&lt;BR /&gt;&lt;BR /&gt;Check out&lt;BR /&gt;&lt;A href="http://www.perl.com/pub/r/916" target="_blank"&gt;http://www.perl.com/pub/r/916&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;This describes a module you can use within perl to process the "acct" info. This way you can munge the data how ever you like and not worry about number field "overflows"&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
    <pubDate>Mon, 10 Feb 2003 18:54:17 GMT</pubDate>
    <dc:creator>Rodney Hills</dc:creator>
    <dc:date>2003-02-10T18:54:17Z</dc:date>
    <item>
      <title>Help with AWK script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900912#M104836</link>
      <description>Hi,&lt;BR /&gt;I have written a small script to strip out TOTAL REAL-MIN and HOG-FACTOR from the monthly acct file, fiscrptXX.  I run into problems when the numbers in some columns are so large that they run together.  I have attached a small portion of an acct file with the problem data and also the script I am using which uses AWK to print out the values from column 5 and 8.  Can I instruct awk to read column five as a floating point number with 2 decimal points??  Can I re-format the monacct output with wider column widths??  What is the best way to get around this?  &lt;BR /&gt;Any thoughts are greatly appreciated!&lt;BR /&gt;Thanks,&lt;BR /&gt;Theresa</description>
      <pubDate>Mon, 10 Feb 2003 16:58:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900912#M104836</guid>
      <dc:creator>Theresa Patrie</dc:creator>
      <dc:date>2003-02-10T16:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: Help with AWK script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900913#M104837</link>
      <description>Use "substr" of awk.&lt;BR /&gt;&lt;BR /&gt;awk 'print substr($0,39,13),substr($0,68,12)'&lt;BR /&gt;&lt;BR /&gt;to print those column positions.&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 10 Feb 2003 17:05:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900913#M104837</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-02-10T17:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help with AWK script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900914#M104838</link>
      <description>Hi Theresa:&lt;BR /&gt;&lt;BR /&gt;You can always use the shell to reformat the overlapping columns of your file:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;while read X&lt;BR /&gt;do&lt;BR /&gt;  A=`echo "${X}"|cut -c1-51`&lt;BR /&gt;  B=`echo "${X}"|cut -c52-`&lt;BR /&gt;  echo "${A} ${B}"&lt;BR /&gt;done &amp;lt; infile &amp;gt; outfile&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 10 Feb 2003 17:25:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900914#M104838</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-02-10T17:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help with AWK script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900915#M104839</link>
      <description>If you are to do more with the data, consider using perl's pack:&lt;BR /&gt;&lt;BR /&gt;#!/use/bin/perl&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;my $f1 = "/var/adm/acct/fiscal/fiscrpt".((localtime)[4]+1);&lt;BR /&gt;my $f2 = $f1 . "_numbers";&lt;BR /&gt;&lt;BR /&gt;open my $F, "&amp;lt; $f1" or die "$f1: $!";&lt;BR /&gt;while (&amp;lt;$F&amp;gt;) {&lt;BR /&gt;    my ($cmd, $n, $tot, $cpu, $real, $mean, $min, $hog, $xfer, $read) =&lt;BR /&gt;        grep s/^\s*//,&lt;BR /&gt;        unpack "A9 A7 A12 A10 A13 A8 A8 A8 A13 A11", $_;&lt;BR /&gt;    $real =~ m/^\d/ or next;&lt;BR /&gt;    printf "%13s %8s\n", $real, $min;&lt;BR /&gt;    }&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Feb 2003 18:08:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900915#M104839</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-02-10T18:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: Help with AWK script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900916#M104840</link>
      <description>Rod &amp;amp; James,&lt;BR /&gt;Thanks for the ideas, but unfortunately once the line is read into $X, it loses all of its nice formatting.  I've attached what $X looks like after the "read".  Unless character position can be used on the "read", it is virtually useless after the fact.  The only way I can think to break up the numbers that run together is to read up to only 2 places after a decimal point, but I do not know if this is possible.  &lt;BR /&gt;Procura, I do not know anything about Perl, but would that script take care of the issues I've outlined in my response??  How does that script deal with the numbers that have run together?&lt;BR /&gt;Any other ideas??&lt;BR /&gt;Thanks Again,&lt;BR /&gt;Theresa&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Feb 2003 18:19:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900916#M104840</guid>
      <dc:creator>Theresa Patrie</dc:creator>
      <dc:date>2003-02-10T18:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: Help with AWK script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900917#M104841</link>
      <description>Hi (again) Teresa:&lt;BR /&gt;&lt;BR /&gt;Please run the small script I suggested.  By *double-quoting* the variables in the 'echo' statements, I have preserved the formatting you had in the input file while adding one blank character to separate the merged fields.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 10 Feb 2003 18:24:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900917#M104841</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-02-10T18:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Help with AWK script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900918#M104842</link>
      <description>The unpack splits the line into the fields as declared with the 'my' line, stripping *trailing* spaces for each field. If you want them kept, use a9 and such (small a a.o.t. capital A):&lt;BR /&gt;&lt;BR /&gt;my ($cmd, $n, $tot, $cpu, $real, $mean, $min, $hog, $xfer, $read) = &lt;BR /&gt;unpack "A9 A7 A12 A10 A13 A8 A8 A8 A13 A11", $_;&lt;BR /&gt;&lt;BR /&gt;The grep I had in between stripped off the *leading* space for every field. I did this to be able to filter on the wanted columns starting with a digit. If I leave the grep out, I have to change the next line to&lt;BR /&gt;&lt;BR /&gt;$real =~ m/^\s*\d/ or next;&lt;BR /&gt;&lt;BR /&gt;Enjoy, have FUN! H.Merijn (who still wants an option in the ITRC to paste formatted text and prevent clipping the multiple spaces from nicely formatted tables, so I can finally show how well it works)</description>
      <pubDate>Mon, 10 Feb 2003 18:29:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900918#M104842</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-02-10T18:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Help with AWK script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900919#M104843</link>
      <description>Hi James,&lt;BR /&gt;Sorry I did not look more closely at your response the first time.  It does exactly what I need.  I have a few other special cases to handle, but I think I can take care of those.  You wear your ITRC Olympian status well!!  &lt;BR /&gt;&lt;BR /&gt;Thanks for the explanation, Procura.  Looks like a foreign language to me since I do not know Perl, but I may check into it more closely if I have more time.  Thanks for your input!&lt;BR /&gt;As usual, ITRC comes to the rescue!&lt;BR /&gt;Thanks,&lt;BR /&gt;Theresa</description>
      <pubDate>Mon, 10 Feb 2003 18:43:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900919#M104843</guid>
      <dc:creator>Theresa Patrie</dc:creator>
      <dc:date>2003-02-10T18:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: Help with AWK script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900920#M104844</link>
      <description>If you do go the "perl" route, then I recommend reading the acct records directly.&lt;BR /&gt;&lt;BR /&gt;Check out&lt;BR /&gt;&lt;A href="http://www.perl.com/pub/r/916" target="_blank"&gt;http://www.perl.com/pub/r/916&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;This describes a module you can use within perl to process the "acct" info. This way you can munge the data how ever you like and not worry about number field "overflows"&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 10 Feb 2003 18:54:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900920#M104844</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-02-10T18:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: Help with AWK script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900921#M104845</link>
      <description>Thanks for the info Rod, but I am talking about HP's built in process accounting.  Looks like that Perl routine is for user accounting (passwords etc.)&lt;BR /&gt;Thanks anyway!</description>
      <pubDate>Mon, 10 Feb 2003 19:32:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900921#M104845</guid>
      <dc:creator>Theresa Patrie</dc:creator>
      <dc:date>2003-02-10T19:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: Help with AWK script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900922#M104846</link>
      <description>Hi Theresa ,&lt;BR /&gt;&lt;BR /&gt;to direct awk to read/print a column as floating decimal, you can use the format like in C, in your case, you can add format like this:&lt;BR /&gt;&lt;BR /&gt;awk '{print "%.2f\n", $5}'&lt;BR /&gt;&lt;BR /&gt;I tested it with your sample data, and got the following output of column 5:&lt;BR /&gt;1060.77&lt;BR /&gt;144331.87&lt;BR /&gt;181.58&lt;BR /&gt;73304.79&lt;BR /&gt;3542544.38&lt;BR /&gt;1421.01&lt;BR /&gt;194178.39&lt;BR /&gt;27.79&lt;BR /&gt;17.78&lt;BR /&gt;0.00&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;thanks,&lt;BR /&gt;Gary&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Feb 2003 19:39:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2900922#M104846</guid>
      <dc:creator>Gary Yu</dc:creator>
      <dc:date>2003-02-10T19:39:15Z</dc:date>
    </item>
  </channel>
</rss>

