<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic &amp;quot;if&amp;quot; processing in &amp;quot;awk&amp;quot;. in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/quot-if-quot-processing-in-quot-awk-quot/m-p/4920324#M104362</link>
    <description>I have an "awk" program, in which I can't get the "if" conditions to work:&lt;BR /&gt;&lt;BR /&gt;syminq -sym -v | awk ' &lt;BR /&gt;        /Device Phys/   {DEV=substr($5,11); next} &lt;BR /&gt;        /Product ID/    {PROD=substr($4,1,4); next} &lt;BR /&gt;        /Capacity/      {CAP=$5; next} &lt;BR /&gt;        /12-digit Symm/ {ARRAY=substr($5,9); next} &lt;BR /&gt;        /Device Symm/   {LUN=$5; next} &lt;BR /&gt;        /    Device Ty/ {DEVTYP=substr($4,1,3); next}   #  BCV or REG &lt;BR /&gt;        /Volume Logix/  {VCM=$5; next} &lt;BR /&gt;        /Meta/          {META=$4; next} &lt;BR /&gt;        /VxVM/          {CLRID=substr(ARRAY,3) &lt;BR /&gt;                         TYP=REG &lt;BR /&gt;                         if (META != "N/A") TYP=META &lt;BR /&gt;                         if (DEVTYP = "BCV") TYP=BCV &lt;BR /&gt;                         if (VCM = "YES") TYP="VCM" &lt;BR /&gt;                         print CLRID LUN "000", ARRAY, TYP, DEV, CAP}' \ &lt;BR /&gt;                                | sort &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I just always get "TYP is equal to "VCM", which it's not.  Can someone tell me what I'm doing wrong?</description>
    <pubDate>Tue, 23 Aug 2005 08:40:43 GMT</pubDate>
    <dc:creator>Stuart Abramson</dc:creator>
    <dc:date>2005-08-23T08:40:43Z</dc:date>
    <item>
      <title>"if" processing in "awk".</title>
      <link>https://community.hpe.com/t5/operating-system-linux/quot-if-quot-processing-in-quot-awk-quot/m-p/4920324#M104362</link>
      <description>I have an "awk" program, in which I can't get the "if" conditions to work:&lt;BR /&gt;&lt;BR /&gt;syminq -sym -v | awk ' &lt;BR /&gt;        /Device Phys/   {DEV=substr($5,11); next} &lt;BR /&gt;        /Product ID/    {PROD=substr($4,1,4); next} &lt;BR /&gt;        /Capacity/      {CAP=$5; next} &lt;BR /&gt;        /12-digit Symm/ {ARRAY=substr($5,9); next} &lt;BR /&gt;        /Device Symm/   {LUN=$5; next} &lt;BR /&gt;        /    Device Ty/ {DEVTYP=substr($4,1,3); next}   #  BCV or REG &lt;BR /&gt;        /Volume Logix/  {VCM=$5; next} &lt;BR /&gt;        /Meta/          {META=$4; next} &lt;BR /&gt;        /VxVM/          {CLRID=substr(ARRAY,3) &lt;BR /&gt;                         TYP=REG &lt;BR /&gt;                         if (META != "N/A") TYP=META &lt;BR /&gt;                         if (DEVTYP = "BCV") TYP=BCV &lt;BR /&gt;                         if (VCM = "YES") TYP="VCM" &lt;BR /&gt;                         print CLRID LUN "000", ARRAY, TYP, DEV, CAP}' \ &lt;BR /&gt;                                | sort &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I just always get "TYP is equal to "VCM", which it's not.  Can someone tell me what I'm doing wrong?</description>
      <pubDate>Tue, 23 Aug 2005 08:40:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/quot-if-quot-processing-in-quot-awk-quot/m-p/4920324#M104362</guid>
      <dc:creator>Stuart Abramson</dc:creator>
      <dc:date>2005-08-23T08:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: "if" processing in "awk".</title>
      <link>https://community.hpe.com/t5/operating-system-linux/quot-if-quot-processing-in-quot-awk-quot/m-p/4920325#M104363</link>
      <description>In your if statements, you want to use "==" and not "=".  What you're doing is actually assigning the value rather than testing it, and the return code of an assignment is usually true, so that's why it's working that way.&lt;BR /&gt;&lt;BR /&gt;--Greg</description>
      <pubDate>Tue, 23 Aug 2005 08:52:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/quot-if-quot-processing-in-quot-awk-quot/m-p/4920325#M104363</guid>
      <dc:creator>Greg Vaidman</dc:creator>
      <dc:date>2005-08-23T08:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: "if" processing in "awk".</title>
      <link>https://community.hpe.com/t5/operating-system-linux/quot-if-quot-processing-in-quot-awk-quot/m-p/4920326#M104364</link>
      <description>Don't use "=" to compare, use "==". A single "=" is an assignment which will return true in all your if statements.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 23 Aug 2005 08:56:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/quot-if-quot-processing-in-quot-awk-quot/m-p/4920326#M104364</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-08-23T08:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: "if" processing in "awk".</title>
      <link>https://community.hpe.com/t5/operating-system-linux/quot-if-quot-processing-in-quot-awk-quot/m-p/4920327#M104365</link>
      <description>Your syntax looks ok to me.  It looks like you are testing three different variables to set TYP.  The way its written, each of those if statements will be evaluated in sequence and every time one of them evaluates as true, the value of TYP is overwritten.  The VCM statement being last might be why you always get that as the result.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;if (DEVTYP = "BCV") TYP=BCV &lt;BR /&gt;else if (VCM = "YES") TYP="VCM" &lt;BR /&gt;else (META != "N/A") TYP=META &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 23 Aug 2005 08:59:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/quot-if-quot-processing-in-quot-awk-quot/m-p/4920327#M104365</guid>
      <dc:creator>Pat Lieberg</dc:creator>
      <dc:date>2005-08-23T08:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: "if" processing in "awk".</title>
      <link>https://community.hpe.com/t5/operating-system-linux/quot-if-quot-processing-in-quot-awk-quot/m-p/4920328#M104366</link>
      <description>Ha!  That's what I get for not looking close enough and for typing slow.  Your syntax was wrong.  Greg and Rodney both are right, you need to use ==.</description>
      <pubDate>Tue, 23 Aug 2005 09:00:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/quot-if-quot-processing-in-quot-awk-quot/m-p/4920328#M104366</guid>
      <dc:creator>Pat Lieberg</dc:creator>
      <dc:date>2005-08-23T09:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: "if" processing in "awk".</title>
      <link>https://community.hpe.com/t5/operating-system-linux/quot-if-quot-processing-in-quot-awk-quot/m-p/4920329#M104367</link>
      <description>&lt;BR /&gt;Those == for testing, and a bunch more quotes are needed:&lt;BR /&gt;&lt;BR /&gt;TYP="REG"; &lt;BR /&gt;if (META != "N/A") TYP="META" &lt;BR /&gt;if (DEVTYP == "BCV") TYP="BCV" &lt;BR /&gt;if (VCM == "YES") TYP="VCM" &lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Tue, 23 Aug 2005 09:24:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/quot-if-quot-processing-in-quot-awk-quot/m-p/4920329#M104367</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-08-23T09:24:18Z</dc:date>
    </item>
    <item>
      <title>Re: "if" processing in "awk".</title>
      <link>https://community.hpe.com/t5/operating-system-linux/quot-if-quot-processing-in-quot-awk-quot/m-p/4920330#M104368</link>
      <description>Thanks all.  "=="...</description>
      <pubDate>Wed, 24 Aug 2005 08:03:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/quot-if-quot-processing-in-quot-awk-quot/m-p/4920330#M104368</guid>
      <dc:creator>Stuart Abramson</dc:creator>
      <dc:date>2005-08-24T08:03:58Z</dc:date>
    </item>
  </channel>
</rss>

