- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- "if" processing 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
Forums
Discussions
Discussions
Discussions
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
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
08-23-2005 01:40 AM
08-23-2005 01:40 AM
syminq -sym -v | awk '
/Device Phys/ {DEV=substr($5,11); next}
/Product ID/ {PROD=substr($4,1,4); next}
/Capacity/ {CAP=$5; next}
/12-digit Symm/ {ARRAY=substr($5,9); next}
/Device Symm/ {LUN=$5; next}
/ Device Ty/ {DEVTYP=substr($4,1,3); next} # BCV or REG
/Volume Logix/ {VCM=$5; next}
/Meta/ {META=$4; next}
/VxVM/ {CLRID=substr(ARRAY,3)
TYP=REG
if (META != "N/A") TYP=META
if (DEVTYP = "BCV") TYP=BCV
if (VCM = "YES") TYP="VCM"
print CLRID LUN "000", ARRAY, TYP, DEV, CAP}' \
| sort
I just always get "TYP is equal to "VCM", which it's not. Can someone tell me what I'm doing wrong?
Solved! Go to Solution.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2005 01:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2005 01:56 AM
08-23-2005 01:56 AM
Re: "if" processing in "awk".
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2005 01:59 AM
08-23-2005 01:59 AM
Re: "if" processing in "awk".
Did you mean to use an "else if" statement? You would use that if one of the types is the default and you only want to deviate if certain conditions are true. For example, the code below sets TYP to META unless the if or the else if statement evaluate to true.
if (DEVTYP = "BCV") TYP=BCV
else if (VCM = "YES") TYP="VCM"
else (META != "N/A") TYP=META
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2005 02:00 AM
08-23-2005 02:00 AM
Re: "if" processing in "awk".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2005 02:24 AM
08-23-2005 02:24 AM
Re: "if" processing in "awk".
Those == for testing, and a bunch more quotes are needed:
TYP="REG";
if (META != "N/A") TYP="META"
if (DEVTYP == "BCV") TYP="BCV"
if (VCM == "YES") TYP="VCM"
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 01:03 AM
08-24-2005 01:03 AM