Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

First script with Awk

Status
Not open for further replies.

jpillonel

Programmer
Dec 17, 2003
61
CH
Hello,

I'm currently writing my first script in ksh and I'm trying to use awk to manipulate some lines.

I'm writing this script to extract Logical Volume informations on a AIX server to generate the creation script.

All the steps are Ok without one.

What I do :
Code:
lsvg $vggroup | grep -iE "VOLUME GROUP|PP SIZE" | awk -f /tmp/test.awk
[/code}


Awk script test.awk:
[code]
{
        if ( $1 == "VOLUME" ) {
                if ( $2 == "GROUP:" ) {
                        print $3
                } else {
                        print "Il y a un probleme"
                }
        } else if ($1 == "VG" ) {
                print $6
        } else {
                print "Aucun caratere trouvé"
        }
}

The result of this command is like this:
datavg
128
datavg2
256
datalvg39
128
rootvg
128

What I want is to have the result like this:
datavg 128
datavg2 256
datalvg39 128
rootvf 128

Does anyone have an idea how to do that ?

Thanks in advance for your help and your comprehension for my first script !
 
or:

{
if ( $1 == "VOLUME" ) {
if ( $2 == "GROUP:" ) {
vg=$3
} else {
print "Il y a un probleme"
}
} else if ($1 == "VG" ) {
print vg,$6
} else {
print "Aucun caratere trouvé"
}
}


HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top