<?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 parsing in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-parsing/m-p/2706598#M903286</link>
    <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Along our earlier lines, for example:&lt;BR /&gt;&lt;BR /&gt;# awk 'BEGIN{min=2;max=5};/vg01/ {for (i=min;i&amp;lt;=max;i++) a[i]+=$i};END {for (i=min;i&amp;lt;=max;i++) print a[i]}' /tmp/data &lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Thu, 18 Apr 2002 19:28:53 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2002-04-18T19:28:53Z</dc:date>
    <item>
      <title>awk parsing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-parsing/m-p/2706595#M903283</link>
      <description>Hi guys,&lt;BR /&gt;&lt;BR /&gt;I posted a question how to calculate sum of all columns. It really helped me. Thank you.&lt;BR /&gt;I have a little different problem though: here an possible file I could have:&lt;BR /&gt;&lt;BR /&gt;/dev/vg00/lvol3 155648 45189 103603 2402 &lt;BR /&gt;/dev/vg00/lvol1 99669 36453 53249 16081 &lt;BR /&gt;/dev/vg00/lvol8 819200 710685 10199 19967 &lt;BR /&gt;/dev/vg00/lvol7 819200 496611 30248 18973 &lt;BR /&gt;/dev/vg01a/lvol3 155648 45189 103603 2402 &lt;BR /&gt;/dev/vg01a/lvol1 99669 36453 53249 16081 &lt;BR /&gt;/dev/vg01a/lvol8 819200 710685 10199 19967 &lt;BR /&gt;/dev/vg01a/lvol7 819200 496611 30248 18973 &lt;BR /&gt;&lt;BR /&gt;and I need the following output:&lt;BR /&gt;/dev/vg00/lvol3 155648 45189 103603 2402 &lt;BR /&gt;/dev/vg00/lvol1 99669 36453 53249 16081 &lt;BR /&gt;/dev/vg00/lvol8 819200 710685 10199 19967 &lt;BR /&gt;/dev/vg00/lvol7 819200 496611 30248 18973 &lt;BR /&gt;&lt;BR /&gt;Total(vg00):    xxxxx  xxxxx  xxxx  xxxx&lt;BR /&gt;&lt;BR /&gt;/dev/vg01a/lvol3 155648 45189 103603 2402 &lt;BR /&gt;/dev/vg01a/lvol1 99669 36453 53249 16081 &lt;BR /&gt;/dev/vg01a/lvol8 819200 710685 10199 19967 &lt;BR /&gt;/dev/vg01a/lvol7 819200 496611 30248 18973&lt;BR /&gt; &lt;BR /&gt;Total(vg01a):    xxxxx  xxxxx  xxxx  xxxx&lt;BR /&gt;&lt;BR /&gt;Any ideas how to use awk in this case?&lt;BR /&gt;&lt;BR /&gt;Thanks a lot!</description>
      <pubDate>Thu, 18 Apr 2002 19:13:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-parsing/m-p/2706595#M903283</guid>
      <dc:creator>andi_1</dc:creator>
      <dc:date>2002-04-18T19:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: awk parsing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-parsing/m-p/2706596#M903284</link>
      <description>To display individual LV's, just add a print to the area that doesn't have a print (wow - I scare myself).&lt;BR /&gt;&lt;BR /&gt;Also change tle bdf to cat your file.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;bdf|grep -v Filesystem|tr -s "  " " "|cut -d" " -f 1-4|sort|&lt;BR /&gt;awk 'BEGIN {&lt;BR /&gt;            prev="";&lt;BR /&gt;            totals[0]=0;&lt;BR /&gt;            totals[1]=0;&lt;BR /&gt;            totals[2]=0;&lt;BR /&gt;            gtotals[0]=0;&lt;BR /&gt;            gtotals[1]=0;&lt;BR /&gt;            gtotals[2]=0;&lt;BR /&gt;            printf("%4s %14s %14s %14s\n","VG","Size","In use","Available");&lt;BR /&gt;           }&lt;BR /&gt;           {split($1,curr,"/");&lt;BR /&gt;            if (prev!="" &amp;amp;&amp;amp; prev!=curr[3])&lt;BR /&gt;               {printf("%4s %14d %14d %14d\n",prev,totals[0],totals[1],totals[2]&lt;BR /&gt;);&lt;BR /&gt;                gtotals[0]+=totals[0];&lt;BR /&gt;                gtotals[1]+=totals[1];&lt;BR /&gt;                gtotals[2]+=totals[2];&lt;BR /&gt;                totals[0]=0;&lt;BR /&gt;                totals[1]=0;&lt;BR /&gt;                totals[2]=0;&lt;BR /&gt;               }&lt;BR /&gt;            prev=curr[3];&lt;BR /&gt;            totals[0]+=$2;&lt;BR /&gt;            totals[1]+=$3;&lt;BR /&gt;            totals[2]+=$4;&lt;BR /&gt;           }&lt;BR /&gt;     END   {&lt;BR /&gt;            gtotals[0]+=totals[0];&lt;BR /&gt;            gtotals[1]+=totals[1];&lt;BR /&gt;            gtotals[2]+=totals[2];&lt;BR /&gt;            printf("%4s %14d %14d %14d\n",prev,totals[0],totals[1],totals[2]);&lt;BR /&gt;            printf("%4s %14s %14s %14s\n","----","--------------","-------------&lt;BR /&gt;-","--------------");&lt;BR /&gt;            printf("%4s %14d %14d %14d\n","Totl",gtotals[0],gtotals[1],gtotals[2&lt;BR /&gt;]);&lt;BR /&gt;           }'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Thu, 18 Apr 2002 19:18:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-parsing/m-p/2706596#M903284</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-04-18T19:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: awk parsing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-parsing/m-p/2706597#M903285</link>
      <description>Hi Harry,&lt;BR /&gt;&lt;BR /&gt;Wow, thanks a lot a such big script!&lt;BR /&gt;Unfortunately, I cannot use bdf, since the file I get is from another system.&lt;BR /&gt;&lt;BR /&gt;So, I just have file.txt....&lt;BR /&gt;&lt;BR /&gt;I assume your script should from simple file as well?&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Apr 2002 19:21:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-parsing/m-p/2706597#M903285</guid>
      <dc:creator>andi_1</dc:creator>
      <dc:date>2002-04-18T19:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: awk parsing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-parsing/m-p/2706598#M903286</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Along our earlier lines, for example:&lt;BR /&gt;&lt;BR /&gt;# awk 'BEGIN{min=2;max=5};/vg01/ {for (i=min;i&amp;lt;=max;i++) a[i]+=$i};END {for (i=min;i&amp;lt;=max;i++) print a[i]}' /tmp/data &lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 18 Apr 2002 19:28:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-parsing/m-p/2706598#M903286</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-04-18T19:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: awk parsing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-parsing/m-p/2706599#M903287</link>
      <description>Slight more changes than I thought, this should pretty much do, except maybe for formatting.&lt;BR /&gt;&lt;BR /&gt;tr -s "  " " "|cut -d" " -f 1-4|sort|&lt;BR /&gt;awk 'BEGIN {&lt;BR /&gt;            prev="";&lt;BR /&gt;            totals[0]=0;&lt;BR /&gt;            totals[1]=0;&lt;BR /&gt;            totals[2]=0;&lt;BR /&gt;            gtotals[0]=0;&lt;BR /&gt;            gtotals[1]=0;&lt;BR /&gt;            gtotals[2]=0;&lt;BR /&gt;            printf("%24s %14s %14s %14s\n","VG","Size","In use","Available");&lt;BR /&gt;           }&lt;BR /&gt;           {&lt;BR /&gt;            split($1,curr,"/");&lt;BR /&gt;            if (prev!="" &amp;amp;&amp;amp; prev!=curr[3])&lt;BR /&gt;               {printf("%24s %14d %14d %14d\n",prev,totals[0],totals[1],totals[2&lt;BR /&gt;]);&lt;BR /&gt;                printf "\n";&lt;BR /&gt;                gtotals[0]+=totals[0];&lt;BR /&gt;                gtotals[1]+=totals[1];&lt;BR /&gt;                gtotals[2]+=totals[2];&lt;BR /&gt;                totals[0]=0;&lt;BR /&gt;                totals[1]=0;&lt;BR /&gt;                totals[2]=0;&lt;BR /&gt;               }&lt;BR /&gt;            printf("%24s %14d %14d %14d\n",$1,$2,$3,$4);&lt;BR /&gt;            prev=curr[3];&lt;BR /&gt;            totals[0]+=$2;&lt;BR /&gt;            totals[1]+=$3;&lt;BR /&gt;            totals[2]+=$4;&lt;BR /&gt;           }&lt;BR /&gt;     END   {&lt;BR /&gt;            gtotals[0]+=totals[0];&lt;BR /&gt;            gtotals[1]+=totals[1];&lt;BR /&gt;            gtotals[2]+=totals[2];&lt;BR /&gt;            printf("%24s %14d %14d %14d\n",prev,totals[0],totals[1],totals[2]);&lt;BR /&gt;            printf("%24s %14s %14s %14s\n","----","--------------","------------&lt;BR /&gt;--","--------------");&lt;BR /&gt;            printf("%24s %14d %14d %14d\n","Totl",gtotals[0],gtotals[1],gtotals[&lt;BR /&gt;2]);&lt;BR /&gt;           }'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Apr 2002 19:31:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-parsing/m-p/2706599#M903287</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-04-18T19:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: awk parsing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-parsing/m-p/2706600#M903288</link>
      <description>Lz,&lt;BR /&gt;&lt;BR /&gt;Same like before ...&lt;BR /&gt;&lt;BR /&gt;awk '/vg00/{t1=t1+$2;t2=t2+$3;t3=t3+$3;t4=t4+$4;} END {print "Total(vg00): ", t1,t2,t3,t4}' testfile&lt;BR /&gt;&lt;BR /&gt;awk '/vg01a/{t1=t1+$2;t2=t2+$3;t3=t3+$3;t4=t4+$4;} END {print "Total(vg01a): ", t1,t2,t3,t4}' testfile&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Shabu</description>
      <pubDate>Thu, 18 Apr 2002 19:38:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-parsing/m-p/2706600#M903288</guid>
      <dc:creator>SHABU KHAN</dc:creator>
      <dc:date>2002-04-18T19:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: awk parsing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-parsing/m-p/2706601#M903289</link>
      <description># perl -nae 'm:^/dev/([^/]+):;for(1..4){$d{$1}[0][$_]+=$F[$_]};push@{$d{$1}},$_;END{for(keys%d){@d=@{$d{$_}};$d=shift@d;print@d,"Total($_):@{$d}\n"}}' logfile</description>
      <pubDate>Thu, 18 Apr 2002 19:52:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-parsing/m-p/2706601#M903289</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-04-18T19:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: awk parsing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-parsing/m-p/2706602#M903290</link>
      <description>Lz,&lt;BR /&gt;&lt;BR /&gt;If you want this in the format that you specified ... execute this script:&lt;BR /&gt;&lt;BR /&gt;prompt&amp;gt;cat myscript&lt;BR /&gt;&lt;BR /&gt;-------------&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;rm -f /tmp/testfile.out&lt;BR /&gt;&lt;BR /&gt;grep "vg00" testfile &amp;gt;&amp;gt; /tmp/testfile.out&lt;BR /&gt;echo " " &amp;gt;&amp;gt; /tmp/testfile.out&lt;BR /&gt;awk '/vg00/{t1=t1+$2;t2=t2+$3;t3=t3+$3;t4=t4+$4;} END {print "Total(vg00): ", t1,t2,t3,t4}' testfile &amp;gt;&amp;gt; /tmp/testfile.out&lt;BR /&gt;echo " " &amp;gt;&amp;gt; /tmp/testfile.out&lt;BR /&gt;grep "vg01a" testfile &amp;gt;&amp;gt; /tmp/testfile.out&lt;BR /&gt;echo " " &amp;gt;&amp;gt; /tmp/testfile.out&lt;BR /&gt;awk '/vg01a/{t1=t1+$2;t2=t2+$3;t3=t3+$3;t4=t4+$4;} END {print "Total(vg01a): ", t1,t2,t3,t4}' testfile &amp;gt;&amp;gt; /tmp/testfile.out&lt;BR /&gt;&lt;BR /&gt;-------------&lt;BR /&gt;prompt&amp;gt;chmod 755 myscript&lt;BR /&gt;prompt&amp;gt;./myscript&lt;BR /&gt;prompt&amp;gt;cat /tmp/testfile.out&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Shabu</description>
      <pubDate>Thu, 18 Apr 2002 19:57:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-parsing/m-p/2706602#M903290</guid>
      <dc:creator>SHABU KHAN</dc:creator>
      <dc:date>2002-04-18T19:57:52Z</dc:date>
    </item>
  </channel>
</rss>

