- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: print fields using 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
тАО04-24-2007 04:34 AM
тАО04-24-2007 04:34 AM
Re: print fields suing awk
# awk '/VOLUME GROUP/{if(a) printf("%s ",a);a=$3}
/PP SIZE/{if(b) printf("%s ",b);b=$6}
/TOTAL PPs/{if(c) printf("%s ",c);c=$6}
/FREE PPs/{if(d) printf("%s\n",d);d=$6}
END{print a,b,c,d}' inp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2007 11:44 PM
тАО04-24-2007 11:44 PM
Re: print fields suing awk
both examples are good however sandman I will toruble shoot your example and get back to you as no output is displayed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2007 03:02 PM - edited тАО10-02-2011 09:45 PM
тАО04-25-2007 03:02 PM - edited тАО10-02-2011 09:45 PM
Re: print fields using awk
>I will trouble shoot your example and get back to you as no output is displayed.
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.
Here my suggested changes that prints complete lines:
awk '
BEGIN { VG=""; SZ=""; FREE=""; TOT="" }
/VOLUME GROUP/ {
if (VG) print VG "," SZ "," FREE "," TOT
VG=$3
}
/PP SIZE/ {SZ=$6}
/TOTAL PPs/ {TOT=$6}
/FREE PPs/ {FREE=$6}
END { print VG "," SZ "," FREE "," TOT }'
The BEGIN isn't strictly needed.
You could use OFS like JRF did in his print.
- « Previous
-
- 1
- 2
- Next »