- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: getting fields to print 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
тАО07-31-2007 04:19 AM
тАО07-31-2007 04:19 AM
--> ./asm.ksh as_oracle
Report Run Date
--------------------------
31-JUL-2007 16:23:08
Server
---------------
heidegger
Disk Group Total Mb Free Mb
-------------------- -------- ---------
ASM_DATA 73728 20495
ASM_FLASH 110592 96233
the information i require is:
ASM_DATA,73728,20495
ASM_FLASH,110592,96233
so I have attempted the syntax:
awk 'NR>11 {if ($1~/ASM_DATA/) {OFS=",";print $1,$2,$3}}; {if ($1~/ASM_FLASH/) {OFS=",";print $1,$2,$3}}'
This does work however I want to know if this is the best code to run, as I am learning awk I want to ensure my knowledge is complete.
Thanks
Chris.
Solved! Go to Solution.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2007 04:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2007 04:30 AM
тАО07-31-2007 04:30 AM
Re: getting fields to print in awk
Use a 'BEGIN' block to set your OFS; avoid the line-number check and simply match an either/or pattern:
# awk 'BEGIN{OFS=","};{if ($1~/ASM_DATA/||$1~/ASM_FLASH/) {print $1,$2,$3}}'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2007 04:42 AM
тАО07-31-2007 04:42 AM
Re: getting fields to print in awk
will will have a play with yours sandman :)
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2007 04:44 AM
тАО07-31-2007 04:44 AM
Re: getting fields to print in awk
and I'll rephrase my last comment
I'll have a play with your code sandman!!
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2007 05:45 AM
тАО07-31-2007 05:45 AM
Re: getting fields to print in awk
Thanks for trying the code I posted though the play on words escapes me ;)