- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: "if" processing in "awk".
Categories
Company
Local Language
Forums
Discussions
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Knowledge Base
Forums
Discussions
- Cloud Mentoring and Education
- Software - General
- HPE OneView
- HPE Ezmeral Software platform
- HPE OpsRamp
Knowledge Base
Discussions
Forums
Discussions
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
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