<?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 on vgdisplay output in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354336#M712944</link>
    <description>Assuming data is stored in a file data, then &lt;BR /&gt;&lt;BR /&gt;for i in `cat data`&lt;BR /&gt;do&lt;BR /&gt;if [ $i = "VG" ]&lt;BR /&gt;then&lt;BR /&gt;echo&lt;BR /&gt;fi&lt;BR /&gt;echo "$i \c"&lt;BR /&gt;done&lt;BR /&gt;echo&lt;BR /&gt;&lt;BR /&gt;Note: This script does not put , (comma).&lt;BR /&gt;&lt;BR /&gt;sks</description>
    <pubDate>Wed, 11 Aug 2004 06:47:44 GMT</pubDate>
    <dc:creator>Sanjay Kumar Suri</dc:creator>
    <dc:date>2004-08-11T06:47:44Z</dc:date>
    <item>
      <title>awk on vgdisplay output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354334#M712942</link>
      <description>I have a big file with vgdisplay output a sample of which is below:&lt;BR /&gt;&lt;BR /&gt;---&lt;BR /&gt;VG Name /dev/vgbackup  &lt;BR /&gt;Max PV 16  &lt;BR /&gt;Cur PV 2  &lt;BR /&gt;Max PE per PV 59466&lt;BR /&gt;PE Size (Mbytes) 16 &lt;BR /&gt;VG Name /dev/vgtbl10  &lt;BR /&gt;Max PV 16  &lt;BR /&gt;Cur PV 16  &lt;BR /&gt;Max PE per PV 1023&lt;BR /&gt;PE Size (Mbytes) 4 &lt;BR /&gt;VG Name /dev/vgredo  &lt;BR /&gt;Max PV 16  &lt;BR /&gt;Cur PV 10  &lt;BR /&gt;Max PE per PV 1016&lt;BR /&gt;PE Size (Mbytes) 4 &lt;BR /&gt;VG Name /dev/rdvgcp  &lt;BR /&gt;Max PV 16  &lt;BR /&gt;Cur PV 3  &lt;BR /&gt;Max PE per PV 13071&lt;BR /&gt;PE Size (Mbytes) 16&lt;BR /&gt;----------&lt;BR /&gt;I need the Record Separator as VG Name. That means each record is starting from VG Name up to PE Size (5 lines).&lt;BR /&gt;&lt;BR /&gt;VG Name /dev/vgbackup  &lt;BR /&gt;Max PV 16  &lt;BR /&gt;Cur PV 2  &lt;BR /&gt;Max PE per PV 59466&lt;BR /&gt;PE Size (Mbytes) 16 &lt;BR /&gt;&lt;BR /&gt;I need to use awk which should consider the first five lines as a record then print it on a single line separated by comma (,) &lt;BR /&gt;&lt;BR /&gt;So the output should be something like this:&lt;BR /&gt;VG Name,/dev/vgbackup,Max PV,16,Cur PV,2,Max PE per PV,59466,PE Size (Mbytes),16 &lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Rasheed.</description>
      <pubDate>Wed, 11 Aug 2004 06:27:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354334#M712942</guid>
      <dc:creator>Rasheed Tamton</dc:creator>
      <dc:date>2004-08-11T06:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: awk on vgdisplay output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354335#M712943</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Since 5 lines each time&lt;BR /&gt;&lt;BR /&gt;let x=0&lt;BR /&gt;outline=""&lt;BR /&gt;  cat $1|while read line&lt;BR /&gt;  do&lt;BR /&gt;    let x=$x+1&lt;BR /&gt;      if [ "$x" -eq 1 ]&lt;BR /&gt;      then&lt;BR /&gt;        outline=$line&lt;BR /&gt;      else&lt;BR /&gt;       outline=$outline","$line&lt;BR /&gt;     fi&lt;BR /&gt;    if [ "$x" -eq "5" ]&lt;BR /&gt;    then&lt;BR /&gt;      echo "$outline"&lt;BR /&gt;      let x=0&lt;BR /&gt;    fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;File is parameter&lt;BR /&gt;&lt;BR /&gt;             Steve Steel</description>
      <pubDate>Wed, 11 Aug 2004 06:45:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354335#M712943</guid>
      <dc:creator>Steve Steel</dc:creator>
      <dc:date>2004-08-11T06:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: awk on vgdisplay output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354336#M712944</link>
      <description>Assuming data is stored in a file data, then &lt;BR /&gt;&lt;BR /&gt;for i in `cat data`&lt;BR /&gt;do&lt;BR /&gt;if [ $i = "VG" ]&lt;BR /&gt;then&lt;BR /&gt;echo&lt;BR /&gt;fi&lt;BR /&gt;echo "$i \c"&lt;BR /&gt;done&lt;BR /&gt;echo&lt;BR /&gt;&lt;BR /&gt;Note: This script does not put , (comma).&lt;BR /&gt;&lt;BR /&gt;sks</description>
      <pubDate>Wed, 11 Aug 2004 06:47:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354336#M712944</guid>
      <dc:creator>Sanjay Kumar Suri</dc:creator>
      <dc:date>2004-08-11T06:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: awk on vgdisplay output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354337#M712945</link>
      <description>You can get your results using the following awk of ,&lt;BR /&gt;&lt;BR /&gt;# awk '{ if ( NR %5 == 4 ) printf $1" "$2" "$3" "$4","$5","&lt;BR /&gt; if ( NR %5 == 0 ) printf $1" "$2" "$3","$4"\n"&lt;BR /&gt;if ( NR %5 == 1 || NR %5 == 2 || NR %5 == 3 )&lt;BR /&gt; printf $1" "$2","$3","&lt;BR /&gt; }' filename&lt;BR /&gt;&lt;BR /&gt;Results&lt;BR /&gt;--------&lt;BR /&gt;&lt;BR /&gt;VG Name,/dev/vgbackup,Max PV,16,Cur PV,2,Max PE per PV,59466,PE Size (Mbytes),16&lt;BR /&gt;VG Name,/dev/vgtbl10,Max PV,16,Cur PV,16,Max PE per PV,1023,PE Size (Mbytes),4&lt;BR /&gt;VG Name,/dev/vgredo,Max PV,16,Cur PV,10,Max PE per PV,1016,PE Size (Mbytes),4&lt;BR /&gt;VG Name,/dev/rdvgcp,Max PV,16,Cur PV,3,Max PE per PV,13071,PE Size (Mbytes),16&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Aug 2004 06:58:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354337#M712945</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-08-11T06:58:54Z</dc:date>
    </item>
    <item>
      <title>Re: awk on vgdisplay output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354338#M712946</link>
      <description>If you would be interested in a perl one-liner-&lt;BR /&gt; &lt;BR /&gt;perl -ne 'chomp; $line=/^VG Name/ ? $_ : $line.",".$_; print $line,"\n" if /^PE Size/' vgoutputfile&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Wed, 11 Aug 2004 08:46:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354338#M712946</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2004-08-11T08:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: awk on vgdisplay output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354339#M712947</link>
      <description>I did something similar to do a mass build of different vgs.. &lt;BR /&gt;&lt;BR /&gt;#/home/scripts/volbuild &lt;BR /&gt;# more volbuild&lt;BR /&gt;cd /pei/peitools/bin&lt;BR /&gt;echo 'This script will build and create database space,&lt;BR /&gt;      Please not you should know about how much disk space is required&lt;BR /&gt;      and available.. Below is a listing of free space in existing&lt;BR /&gt;      Volume Groups'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;echo "Enter Enter District ID:"&lt;BR /&gt;read district&lt;BR /&gt;for vg in `grep "LV Name" vg.txt |awk '{print $3}' |grep dbs |grep -v vg00 |grep -v log |grep -v root |grep -v tmp |grep&lt;BR /&gt; $district`&lt;BR /&gt; do&lt;BR /&gt;        vgrp=`lvdisplay $vg |grep "VG Name"|awk '{print $3}'`&lt;BR /&gt;                echo -------- Logical Volume `lvdisplay $vg |grep "LV Name"` --------&lt;BR /&gt;                                lvdisplay $vg |grep "LV Name"&lt;BR /&gt;                                echo $vgrp&lt;BR /&gt;                                lvdisplay $vg |grep "LV Size"&lt;BR /&gt;                                vgdisplay $vgrp |grep Free&lt;BR /&gt;export dbspace=`lvdisplay $vg |grep "LV Name" |awk '{print substr($3, 11, 6)}'`&lt;BR /&gt;export  vgrp=`lvdisplay $vg |grep "VG Name"|awk '{print $3}'`&lt;BR /&gt;export nvol=`lvdisplay $vg |grep "LV Name" |awk '{print substr($3, 17, 1)}'`&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;if [ -z "$nvol" ]&lt;BR /&gt;        then export nvol=0&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;        export i=`expr $nvol + 1`&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;echo "Enter Size of Volume"&lt;BR /&gt;read size&lt;BR /&gt;export size&lt;BR /&gt;echo lvcreate -L $size -n $dbspace$i $vgrp&lt;BR /&gt;cd $vgrp&lt;BR /&gt;echo chown informix:informix r$dbspace$i&lt;BR /&gt;echo chmod 660 r$dbspace$i&lt;BR /&gt;export fname=r$dbspace$i&lt;BR /&gt;&lt;BR /&gt;cd /dev/online&lt;BR /&gt;#&lt;BR /&gt;ls $fname&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;echo ln -s $vgrp/$fname $dbspace$i&lt;BR /&gt;echo onspaces -a $dbspace$i -p /dev/online/$fname -o 0 -s "$size"000&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Aug 2004 08:07:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354339#M712947</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2004-08-12T08:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: awk on vgdisplay output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354340#M712948</link>
      <description>&lt;BR /&gt;Hmmm, my vgdisplay (11.23) shows more lines. For example:&lt;BR /&gt;&lt;BR /&gt;VG Name                     /dev/vg00&lt;BR /&gt;VG Write Access             read/write&lt;BR /&gt;VG Status                   available&lt;BR /&gt;Max LV                      255&lt;BR /&gt;Cur LV                      8&lt;BR /&gt;Open LV                     8&lt;BR /&gt;Max PV                      16&lt;BR /&gt;Cur PV                      1&lt;BR /&gt;Act PV                      1&lt;BR /&gt;Max PE per PV               4328&lt;BR /&gt;&lt;BR /&gt;So I would recommend you protect against that and select 'just what you need'.&lt;BR /&gt;&lt;BR /&gt;My perl 'one-liner' woudl be explicit about matches:&lt;BR /&gt;&lt;BR /&gt;vgdisplay -v | perl -ne '&lt;BR /&gt;if (/^(VG Name|Max PV|Max PE per PV)\s+(\S+)/)&lt;BR /&gt;{ $x .= "$1,$2," }&lt;BR /&gt;if (/(PE Size \(Mbytes\))\s+(\d+)/){print "$x$1,$2\n"; $x=""}'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This says:&lt;BR /&gt;If the string starts with one of 4 expliciti strings, then glue that string , plus a comma, plus the next series of non-whitespace, plus a comma to a workstring 'x'.&lt;BR /&gt;Look explicitly for the last match and print temp + last.&lt;BR /&gt;&lt;BR /&gt;Result for me:&lt;BR /&gt;&lt;BR /&gt;VG Name,/dev/vg00,Max PV,16,Max PE per PV,4328,PE Size (Mbytes),16&lt;BR /&gt;VG Name,/dev/vg_oltp,Max PV,16,Max PE per PV,65535,PE Size (Mbytes),32&lt;BR /&gt;:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Aug 2004 10:22:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354340#M712948</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-08-12T10:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: awk on vgdisplay output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354341#M712949</link>
      <description>&lt;BR /&gt;Just for yucks...&lt;BR /&gt;&lt;BR /&gt;It bothered me I could not come up with a nice generic way to catch the words before the value. So without hardcoding files numbers/names.&lt;BR /&gt;&lt;BR /&gt;first potential solution... just take enough interesting bytes for the name, then trim some.&lt;BR /&gt;&lt;BR /&gt; awk '{n=substr($0,1,22);gsub(/ +/," ",n);x=x n "," $NF ","}/^PE S/{sub(/.$/,"",x); print x;x=""}'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Second potential solution... first collapse all multiple spaces to single space. The use the position of the last field as the end of the name + 2:&lt;BR /&gt;&lt;BR /&gt;awk '{gsub(/ +/," ");x=x substr($0,1,index($0,$NF)-2) "," $NF ","}/^PE S/{sub(/.$/,"",x); print x;x=""}'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Ok.... back to real work.&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Aug 2004 11:10:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354341#M712949</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-08-12T11:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: awk on vgdisplay output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354342#M712950</link>
      <description>Based on the output shown this is AWK ugly.&lt;BR /&gt;&lt;BR /&gt;You want a ,(comma) as seperator between the field label and the data.&lt;BR /&gt;IE:&lt;BR /&gt;fieldname, data, fieldname, data, etc&lt;BR /&gt;&lt;BR /&gt;This worked on my system:&lt;BR /&gt; vgdisplay | awk '&lt;BR /&gt;    ( $0 ~ /VG Name/ ) {&lt;BR /&gt;          for (i = 1; i &amp;lt;= 4; i++)&lt;BR /&gt;            {&lt;BR /&gt;              while   (gsub(/  /," "));&lt;BR /&gt;              fields=split($0,data," ")&lt;BR /&gt;              for (f = 1; f &amp;lt; fields; f++)&lt;BR /&gt;                 printf("%s ",data[f])&lt;BR /&gt;              printf(",%s,",data[fields])&lt;BR /&gt;              getline&lt;BR /&gt;            }&lt;BR /&gt;              while   (gsub(/  /," "));&lt;BR /&gt;              fields=split($0,data," ")&lt;BR /&gt;              for (f = 1; f &amp;lt; fields; f++)&lt;BR /&gt;                 printf("%s ",data[f])&lt;BR /&gt;              printf(",%s\n",data[fields])&lt;BR /&gt;           }&lt;BR /&gt;  '&lt;BR /&gt;&lt;BR /&gt;vgdisplay | awk '    #imput stream to awk&lt;BR /&gt;( $0 ~ /VG Name/ ) { # find first record&lt;BR /&gt;&lt;BR /&gt;for (i = 1; i &amp;lt;= 4; i++) #next four lines&lt;BR /&gt;   {&lt;BR /&gt;while   (gsub(/  /," ")); #reduce white space&lt;BR /&gt;&lt;BR /&gt;fields=split($0,data," ") #split into fields&lt;BR /&gt;#print all the line fields except last&lt;BR /&gt;#this is field name&lt;BR /&gt;for (f = 1; f &amp;lt; fields; f++) &lt;BR /&gt;            printf("%s ",data[f])&lt;BR /&gt;#print a comma and then the data field&lt;BR /&gt;              printf(",%s,",data[fields])&lt;BR /&gt;              getline&lt;BR /&gt;            }&lt;BR /&gt;#Do the last line as above ending in a &lt;BR /&gt;# linefeed&lt;BR /&gt;              while   (gsub(/  /," "));&lt;BR /&gt;              fields=split($0,data," ")&lt;BR /&gt;              for (f = 1; f &amp;lt; fields; f++)&lt;BR /&gt;                 printf("%s ",data[f])&lt;BR /&gt;              printf(",%s\n",data[fields])&lt;BR /&gt;           }&lt;BR /&gt;&lt;BR /&gt;  '&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Aug 2004 11:49:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-on-vgdisplay-output/m-p/3354342#M712950</guid>
      <dc:creator>Rory R Hammond</dc:creator>
      <dc:date>2004-08-12T11:49:06Z</dc:date>
    </item>
  </channel>
</rss>

