- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: handling arrays in "awk"
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2005 05:51 AM
тАО09-15-2005 05:51 AM
I am collecting all of the PVs in an LV in an array PV[], but I don't know how to print them all out on one line.
Can one of you "awk wizards" help me, please?
for VGROUP in $VOLGRPS
do
LVOLS=$( vgdisplay -v $VGROUP | grep "LV Name" | sort | awk '{print $3}' )
set $LVOLS
NLVS=$#
print $VGROUP $NLVS
for LV in $LVOLS
do
LVNAME=$( basename $LV )
lvdisplay -v $LV | awk -v LVName=$LVNAME '
/Mirror/ {MIRS = $3}
/LV Size/ {SIZE = $4}
/Current LE/ {LES = $3}
/Allocated PE/ {PES = $3}
/Stripes/ {STRIPES = $2}
/ \/dev\/dsk/ {PV[CNT] = substr($1,10);
CNT = CNT + 1}
END {print LVName, MIRS, SIZE, LES, \
PES, STRIPES, CNT, PV[$@]} ........<===
'
done
Solved! Go to Solution.
- Tags:
- lvdisplay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2005 06:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2005 06:48 AM
тАО09-15-2005 06:48 AM
Re: handling arrays in "awk"
END {
printf("%s %s %s %s %s %s %s", LVName, MIRS, SIZE, LES, PES, STRIPES, CNT);
#use printf so there is no newline
for ( i in PV ) printf(" %s", PV[i]);
#although this isn't garanteed to be in order
# to be sure they are in order:
#for (i=0;i++;i
printf("\n");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2005 08:33 AM
тАО09-15-2005 08:33 AM
Re: handling arrays in "awk"
END {print
regards!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2005 05:56 PM
тАО09-15-2005 05:56 PM
Re: handling arrays in "awk"
for VGROUP in $VOLGRPS
do
LVOLS=$( vgdisplay -v $VGROUP | grep "LV Name" | sort | awk '{print $3}' )
set $LVOLS
NLVS=$#
print "VGROUP\t No. LVs"
print "$VGROUP $NLVS\n"
printf LVName" "MIRS" "SIZE" "LES" "PES" "STRIPES" "PVNAME"\n"
for LV in $LVOLS
do
LVNAME=$(basename $LV )
lvdisplay -v $LV | awk -v LVName=$LVNAME '
/Mirror/ {MIRS = $3}
/LV Size/ {SIZE = $4}
/Current LE/ {LES = $3}
/Allocated PE/ {PES = $3}
/Stripes/ {STRIPES = $2}
/^ +\/dev\/dsk/ {PV[CNT] = substr($1,10);CNT = CNT + 1}
END {printf ("%-6s %-4d %-4d %-3d %-3d %-8s",LVName,MIRS,SIZE,LES,PES,STRIPES); for (s in PV) { printf PV[s]; }printf "\n";}'
done
done
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2005 02:46 AM
тАО09-16-2005 02:46 AM