<?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: print fields suing awk in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987643#M95845</link>
    <description>Hi Chris:&lt;BR /&gt;&lt;BR /&gt;Here's one way.  You can adapt the matching for the FREE and USED portions easily:&lt;BR /&gt;&lt;BR /&gt;# lsvg rootvg|awk '/TOTAL PP/ {split($7,a,/[()]/);print $4,$6,a[2]}'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Tue, 24 Apr 2007 08:48:47 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2007-04-24T08:48:47Z</dc:date>
    <item>
      <title>print fields suing awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987641#M95843</link>
      <description>Hi guys,&lt;BR /&gt;&lt;BR /&gt;I posted a thread earlier but I think I need to elaborate, I am still learning awk and my syntax is all over the place ie prints unexpected fields etc ....&lt;BR /&gt;&lt;BR /&gt;eg I am running these commands on AIX so I hope that doesnt offend the HPUX guru's here ...&lt;BR /&gt;&lt;BR /&gt;eg:&lt;BR /&gt;&lt;BR /&gt;lsvg rootvg&lt;BR /&gt;&lt;BR /&gt;VOLUME GROUP:       rootvg                   VG IDENTIFIER:  0045278a00004c000000010deef5d831&lt;BR /&gt;VG STATE:           active                   PP SIZE:        128 megabyte(s)&lt;BR /&gt;VG PERMISSION:      read/write               TOTAL PPs:      270 (34560 megabytes)&lt;BR /&gt;MAX LVs:            256                      FREE PPs:       72 (9216 megabytes)&lt;BR /&gt;LVs:                11                       USED PPs:       198 (25344 megabytes)&lt;BR /&gt;OPEN LVs:           10                       QUORUM:         1&lt;BR /&gt;TOTAL PVs:          2                        VG DESCRIPTORS: 3&lt;BR /&gt;STALE PVs:          0                        STALE PPs:      0&lt;BR /&gt;ACTIVE PVs:         2                        AUTO ON:        no&lt;BR /&gt;MAX PPs per VG:     32512                                     &lt;BR /&gt;MAX PPs per PV:     1016                     MAX PVs:        32&lt;BR /&gt;LTG size (Dynamic): 256 kilobyte(s)          AUTO SYNC:      no&lt;BR /&gt;HOT SPARE:          no                       BB POLICY:      relocatable &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;from this output I want to print &lt;BR /&gt;&lt;BR /&gt;TOTAL 270  34560&lt;BR /&gt;FREE  72   9216&lt;BR /&gt;USED  198  25344&lt;BR /&gt;&lt;BR /&gt;the problem I am having is determining the field and rows to print in awk ....&lt;BR /&gt;&lt;BR /&gt;any help is much appreciated.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Tue, 24 Apr 2007 08:34:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987641#M95843</guid>
      <dc:creator>lawrenzo</dc:creator>
      <dc:date>2007-04-24T08:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: print fields suing awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987642#M95844</link>
      <description>i should elaborate as the example text is not very clear ...&lt;BR /&gt;&lt;BR /&gt;from the lsvg rootvg the actual fields are:&lt;BR /&gt;&lt;BR /&gt;TOTAL PPs: 270 (34560 megabytes)&lt;BR /&gt;FREE PPs: 72 (9216 megabytes)&lt;BR /&gt;USED PPs: 198 (25344 megabytes)&lt;BR /&gt;&lt;BR /&gt;lsvg rootvg |awk '/PPs:/ &amp;amp;&amp;amp; ! /STALE/ {print ????}'&lt;BR /&gt;&lt;BR /&gt;???? is the problem because the USED field is not $4,$6,$7&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 24 Apr 2007 08:39:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987642#M95844</guid>
      <dc:creator>lawrenzo</dc:creator>
      <dc:date>2007-04-24T08:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: print fields suing awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987643#M95845</link>
      <description>Hi Chris:&lt;BR /&gt;&lt;BR /&gt;Here's one way.  You can adapt the matching for the FREE and USED portions easily:&lt;BR /&gt;&lt;BR /&gt;# lsvg rootvg|awk '/TOTAL PP/ {split($7,a,/[()]/);print $4,$6,a[2]}'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 24 Apr 2007 08:48:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987643#M95845</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-04-24T08:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: print fields suing awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987644#M95846</link>
      <description>Chris,&lt;BR /&gt;&lt;BR /&gt;When you say you had an earlier thread, post a link.&lt;BR /&gt;&lt;BR /&gt;I think this is it.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1121029" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1121029&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I can discern little else from your input, but will give you a little example.&lt;BR /&gt;&lt;BR /&gt;Lets say I have output that looks like this:&lt;BR /&gt;&lt;BR /&gt;Field1   Field2  Field3&lt;BR /&gt;&lt;BR /&gt;To print it.&lt;BR /&gt;&lt;BR /&gt;cat (whatever) | awk '{ print $1 $2 $3}'&lt;BR /&gt;&lt;BR /&gt;To get field two into a variable&lt;BR /&gt;&lt;BR /&gt;F2=$(cat $DATA | awk '{ print $2 }')&lt;BR /&gt;&lt;BR /&gt;Try and take some time to explain the problem and give background.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Tue, 24 Apr 2007 08:49:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987644#M95846</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2007-04-24T08:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: print fields suing awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987645#M95847</link>
      <description>Hiya,&lt;BR /&gt;&lt;BR /&gt;Usually I call sed to the rescue in such situations (sed &amp;amp; awk get along great).&lt;BR /&gt;&lt;BR /&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;# lsvg rootvg | sed -ne 's/[()]//g' -e 's/.*\(TOTAL PP.*\)/\1/p' -e 's/.*\(FREE PP.*\)/\1/p' -e 's/.*\(USED PP.*\)/\1/p'&lt;BR /&gt;&lt;BR /&gt;After that, the awk becomes way easier ;-)&lt;BR /&gt;&lt;BR /&gt; |awk '{print $1,$3,$4}'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Wout</description>
      <pubDate>Tue, 24 Apr 2007 09:01:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987645#M95847</guid>
      <dc:creator>Wouter Jagers</dc:creator>
      <dc:date>2007-04-24T09:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: print fields suing awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987646#M95848</link>
      <description>I think you're wanting something like this since the line with USED isn't the same number of fields as the other two:&lt;BR /&gt;&lt;BR /&gt;lsvg rootvg | awk '/PPs:/ &amp;amp;&amp;amp; ! /STALE/ {if ($1 == "LVs:") print $3, $5, $6 else print $4, $6, $7}' | sed 's/(//'&lt;BR /&gt;&lt;BR /&gt;The sed is just to get rid of that ( in the third printed field.</description>
      <pubDate>Tue, 24 Apr 2007 09:02:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987646#M95848</guid>
      <dc:creator>Jeff_Traigle</dc:creator>
      <dc:date>2007-04-24T09:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: print fields suing awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987647#M95849</link>
      <description>Hi (again) Chris:&lt;BR /&gt;&lt;BR /&gt;Since the "USED" fields are not ordinally in the same place as the "TOTAL" or "FREE" lines, we can do this:&lt;BR /&gt;&lt;BR /&gt;# lsvg rootvg | awk '/TOTAL PP|FREE PP/ {split($7,a,/[()]/);print $4,$6,a[2]};/USED PP/ {split($6,a,/[()]/);print $3,$5,a[2]}' &lt;BR /&gt;&lt;BR /&gt;TOTAL 270 34560&lt;BR /&gt;FREE 72 9216&lt;BR /&gt;USED 198 25344&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 24 Apr 2007 09:11:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987647#M95849</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-04-24T09:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: print fields suing awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987648#M95850</link>
      <description>Chris,&lt;BR /&gt;my sad effort would be along the lines of:&lt;BR /&gt;awk '{print $(NF-4),$(NF-3),$(NF-2),$(NF-1)}'</description>
      <pubDate>Tue, 24 Apr 2007 09:17:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987648#M95850</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-04-24T09:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: print fields suing awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987649#M95851</link>
      <description>thread reopened because the output was not correct.&lt;BR /&gt;&lt;BR /&gt;Brief explaination ...&lt;BR /&gt;&lt;BR /&gt;we upload stats to a central DB which then give us peformance and capacity data, this data will tell us when we will need to add more disk to the system.&lt;BR /&gt;&lt;BR /&gt;The capacity manager wants the output to appear as below without the headers because he will set this at his end:&lt;BR /&gt;&lt;BR /&gt;volumegroup,PP SIZE,FREE PPs,TOTAL PPs&lt;BR /&gt;&lt;BR /&gt;rootvg,128,72,270&lt;BR /&gt;&lt;BR /&gt;Thanks again</description>
      <pubDate>Tue, 24 Apr 2007 09:58:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987649#M95851</guid>
      <dc:creator>lawrenzo</dc:creator>
      <dc:date>2007-04-24T09:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: print fields suing awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987650#M95852</link>
      <description>Hi Chris:&lt;BR /&gt;&lt;BR /&gt;# lsvg rootvg | awk 'NR==1 {VG=$3};/PP SIZE/ {SZ=$6};/FREE PP/ {FREE=$6};/TOTAL PP/ {TOT=$6};END{OFS=",";print VG,SZ,FREE,TOT}' &lt;BR /&gt;&lt;BR /&gt;rootvg,128,72,270&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 24 Apr 2007 10:49:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987650#M95852</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-04-24T10:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: print fields suing awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987651#M95853</link>
      <description>&lt;!--!*#--&gt;Try the awk script below. It basically extends JRF's script if there is more than one VG present:&lt;BR /&gt;&lt;BR /&gt;# awk '/VOLUME GROUP/{if(a) printf("%s ",a);a=$3}&lt;BR /&gt;     /PP SIZE/{if(b) printf("%s ",b);b=$6}&lt;BR /&gt;     /TOTAL PPs/{if(c) printf("%s ",c);c=$6}&lt;BR /&gt;     /FREE PPs/{if(d) printf("%s\n",d);d=$6}&lt;BR /&gt;END{print a,b,c,d}' inp</description>
      <pubDate>Tue, 24 Apr 2007 11:34:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987651#M95853</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-04-24T11:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: print fields suing awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987652#M95854</link>
      <description>Thanks guys,&lt;BR /&gt;&lt;BR /&gt;both examples are good however sandman I will toruble shoot your example and get back to you as no output is displayed.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 25 Apr 2007 06:44:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987652#M95854</guid>
      <dc:creator>lawrenzo</dc:creator>
      <dc:date>2007-04-25T06:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: print fields using awk</title>
      <link>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987653#M95855</link>
      <description>&lt;P&gt;&amp;gt;I will trouble shoot your example and get back to you as no output is displayed.&lt;BR /&gt;&lt;BR /&gt;Hmm, I get output if you assume that you made two copies of your initial lsvg output. Sandman does have the free after the total.&lt;BR /&gt;&lt;BR /&gt;Here my suggested changes that prints complete lines:&lt;BR /&gt;awk '&lt;BR /&gt;BEGIN { VG=""; SZ=""; FREE=""; TOT="" }&lt;BR /&gt;/VOLUME GROUP/ {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if (VG) print VG "," SZ "," FREE "," TOT&lt;BR /&gt;&amp;nbsp;&amp;nbsp; VG=$3&lt;BR /&gt;}&lt;BR /&gt;/PP SIZE/ {SZ=$6}&lt;BR /&gt;/TOTAL PPs/ {TOT=$6}&lt;BR /&gt;/FREE PPs/ {FREE=$6}&lt;BR /&gt;END { print VG "," SZ "," FREE "," TOT }'&lt;BR /&gt;&lt;BR /&gt;The BEGIN isn't strictly needed.&lt;BR /&gt;You could use OFS like JRF did in his print.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2011 04:45:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/print-fields-suing-awk/m-p/3987653#M95855</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-10-03T04:45:02Z</dc:date>
    </item>
  </channel>
</rss>

