the script display's list of volume groups followed by physical volumes with in volume group and at the same time the script should display the pvid of physical volume.
what i need is, how to read the line by line from the files...
the below is my script..
echo "List of Volume Groups and Physical Volume:"
while read xxxxxx (the xxxx should read from file reportvg.out)
do
lsvg -p xxxxxx > reportpv.out (the xxxxx is vg anme)
while read xxxxxx ( the xxxx is the pv name from reportpv.out)
do
lspv xxxxx | grep IDENTIFIER ( the xxxx is pv name)
done reportpv.out
done reportvg.out
Don't let era, our local "herder of useless cats", see that ;-)) :
.... awk '{ /PV IDENTIFIER/ print $3 }'....
would do the same as "....grep ...| awk ....", yes?
I have long given up on pointing out that backticks are considered harmful in the Korn shell and "`...`" should be replaced by "$(....)".
And for the audience: please use [ code ]...[ /code ]-tags when posting code. The difference is:
with code-tags:
for MyVG in `lsvg`
do
echo "\n\n Volume Group: $MyVG\n------------------"
for MyPV in `lsvg -p $MyVG|grep -v -e $MyVG -e PV_NAME|awk '{ print $1 }'`
do
MyID=`lspv $MyPV|grep 'PV IDENTIFIER'|awk '{ print $3}'`
echo $MyPV $MyID
done
done
and the same without:
for MyVG in `lsvg`
do
echo "\n\n Volume Group: $MyVG\n------------------"
for MyPV in `lsvg -p $MyVG|grep -v -e $MyVG -e PV_NAME|awk '{ print $1 }'`
do
MyID=`lspv $MyPV|grep 'PV IDENTIFIER'|awk '{ print $3}'`
echo $MyPV $MyID
done
done