<?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 Re: using variables in case command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695457#M843370</link>
    <description>Gary, &lt;BR /&gt;&lt;BR /&gt;The syntax you need will be something like:&lt;BR /&gt;&lt;BR /&gt;var1=$1&lt;BR /&gt;var2='00[1-3]'&lt;BR /&gt;&lt;BR /&gt;case $var1 in&lt;BR /&gt;  $var2) commands ;;&lt;BR /&gt;  *) other commands ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;The issue is how you are assigning your variables. If you know what the allowable range of values for var2 is ahead of time, you can use the above style of assignment to test. &lt;BR /&gt;&lt;BR /&gt;Mayhap if you could post how you're deriving var1 and var2 it would be helpful (if the above isn't what you're after). &lt;BR /&gt;&lt;BR /&gt;Mark</description>
    <pubDate>Fri, 05 Apr 2002 01:59:04 GMT</pubDate>
    <dc:creator>Mark Fenton</dc:creator>
    <dc:date>2002-04-05T01:59:04Z</dc:date>
    <item>
      <title>using variables in case command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695447#M843360</link>
      <description>I've written a script similar to the following...&lt;BR /&gt;&lt;BR /&gt;case $var1 in&lt;BR /&gt;$var2 )&lt;BR /&gt;do stuff ;;&lt;BR /&gt;* )&lt;BR /&gt;do nothing ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;...where $var2 = "001|002|003" but $var2 is not being translated correctly, or at least how I thought it would be. &lt;BR /&gt;If I set $var2 to be a single value (without the pipes) it works fine.&lt;BR /&gt;&lt;BR /&gt;Can anyone advise on the correct syntax?</description>
      <pubDate>Tue, 02 Apr 2002 15:43:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695447#M843360</guid>
      <dc:creator>gary phipps</dc:creator>
      <dc:date>2002-04-02T15:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: using variables in case command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695448#M843361</link>
      <description>Try putting 001|002|003 in single ' quotes.&lt;BR /&gt;$var2 = '001|002|003'&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Apr 2002 15:53:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695448#M843361</guid>
      <dc:creator>hpuxrox</dc:creator>
      <dc:date>2002-04-02T15:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: using variables in case command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695449#M843362</link>
      <description>the pipe is just another character to the shell, not a delimeter.  You can use tabs, or change the FS (field separator) variable to the pipe:&lt;BR /&gt;&lt;BR /&gt;OLD_FS=$FS&lt;BR /&gt;FS="|"&lt;BR /&gt;CASE&lt;BR /&gt;...&lt;BR /&gt;ESAC&lt;BR /&gt;FS=$OLD_FS&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;mark</description>
      <pubDate>Tue, 02 Apr 2002 15:53:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695449#M843362</guid>
      <dc:creator>Mark Greene_1</dc:creator>
      <dc:date>2002-04-02T15:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: using variables in case command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695450#M843363</link>
      <description>The "|" is being translated as logical or in the case statement. Try this instead ..&lt;BR /&gt;&lt;BR /&gt;case $var1 in &lt;BR /&gt;"$var2" ) &lt;BR /&gt;do stuff ;; &lt;BR /&gt;* ) &lt;BR /&gt;do nothing ;; &lt;BR /&gt;esac &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Apr 2002 15:54:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695450#M843363</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2002-04-02T15:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: using variables in case command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695451#M843364</link>
      <description>I totally misunderstood your q, sorry .. why not use pattern matching in the case statement ..?&lt;BR /&gt;&lt;BR /&gt;case $var1 in &lt;BR /&gt;00[1-3] ) &lt;BR /&gt;do stuff ;; &lt;BR /&gt;* ) &lt;BR /&gt;do nothing ;; &lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Apr 2002 16:12:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695451#M843364</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2002-04-02T16:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: using variables in case command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695452#M843365</link>
      <description>&lt;BR /&gt;Gary,&lt;BR /&gt;&lt;BR /&gt;Try escaping the pipe with backslash like this:&lt;BR /&gt;&lt;BR /&gt;...where $var2 = "001\|002\|003"&lt;BR /&gt;&lt;BR /&gt;and then: double quotes var2&lt;BR /&gt;&lt;BR /&gt;case $var1 in &lt;BR /&gt;"${var2}" ) &lt;BR /&gt;do stuff ;; &lt;BR /&gt;* ) &lt;BR /&gt;do nothing ;; &lt;BR /&gt;esac &lt;BR /&gt;&lt;BR /&gt;-Shabu</description>
      <pubDate>Tue, 02 Apr 2002 19:48:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695452#M843365</guid>
      <dc:creator>SHABU KHAN</dc:creator>
      <dc:date>2002-04-02T19:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: using variables in case command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695453#M843366</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;you should always quote substitution, hence:&lt;BR /&gt;case "$var" in&lt;BR /&gt;"$var2) ... ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;Just my $0.02,&lt;BR /&gt;Wodisch&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Apr 2002 22:02:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695453#M843366</guid>
      <dc:creator>Wodisch</dc:creator>
      <dc:date>2002-04-02T22:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: using variables in case command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695454#M843367</link>
      <description>Hi Gary,&lt;BR /&gt;&lt;BR /&gt;You have to put the exact "Constant" into the value of case. You are NOT allowed to do it as you mentioned :&lt;BR /&gt;&lt;BR /&gt;case $var1 in &lt;BR /&gt;$var2 ) &lt;BR /&gt;do stuff ;; &lt;BR /&gt;* ) &lt;BR /&gt;do nothing ;; &lt;BR /&gt;esac &lt;BR /&gt;&lt;BR /&gt;Syntax would be :&lt;BR /&gt;&lt;BR /&gt;case $var1 in &lt;BR /&gt;'001|002|003') &lt;BR /&gt;      do stuff ;; &lt;BR /&gt;* ) &lt;BR /&gt;      do nothing ;; &lt;BR /&gt;esac &lt;BR /&gt;&lt;BR /&gt;No varaibles are allowed to be used in the constant expressions.&lt;BR /&gt;&lt;BR /&gt;Magdi&lt;BR /&gt;</description>
      <pubDate>Wed, 03 Apr 2002 10:01:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695454#M843367</guid>
      <dc:creator>Magdi KAMAL</dc:creator>
      <dc:date>2002-04-03T10:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: using variables in case command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695455#M843368</link>
      <description>Hi folks,&lt;BR /&gt;&lt;BR /&gt;thanks for all the input. I tried all of the above but unfortunately none of them worked. I'll try various combinations of your suggestions and let you know what happens.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Gary.</description>
      <pubDate>Wed, 03 Apr 2002 10:24:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695455#M843368</guid>
      <dc:creator>gary phipps</dc:creator>
      <dc:date>2002-04-03T10:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: using variables in case command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695456#M843369</link>
      <description>how are your populating var1 prior to doing the case?&lt;BR /&gt;&lt;BR /&gt;mark</description>
      <pubDate>Thu, 04 Apr 2002 20:46:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695456#M843369</guid>
      <dc:creator>Mark Greene_1</dc:creator>
      <dc:date>2002-04-04T20:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: using variables in case command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695457#M843370</link>
      <description>Gary, &lt;BR /&gt;&lt;BR /&gt;The syntax you need will be something like:&lt;BR /&gt;&lt;BR /&gt;var1=$1&lt;BR /&gt;var2='00[1-3]'&lt;BR /&gt;&lt;BR /&gt;case $var1 in&lt;BR /&gt;  $var2) commands ;;&lt;BR /&gt;  *) other commands ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;The issue is how you are assigning your variables. If you know what the allowable range of values for var2 is ahead of time, you can use the above style of assignment to test. &lt;BR /&gt;&lt;BR /&gt;Mayhap if you could post how you're deriving var1 and var2 it would be helpful (if the above isn't what you're after). &lt;BR /&gt;&lt;BR /&gt;Mark</description>
      <pubDate>Fri, 05 Apr 2002 01:59:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-variables-in-case-command/m-p/2695457#M843370</guid>
      <dc:creator>Mark Fenton</dc:creator>
      <dc:date>2002-04-05T01:59:04Z</dc:date>
    </item>
  </channel>
</rss>

