<div dir="ltr">I bet you only get the cases evaluated during the script's parsing. I haven't checked that, though.<div><br></div><div>I think this would be a better place for using grep, not case. Using "-F" has the additional advantage that you turn off globbing and regular expressions, since you seem to want to match fixed strings exactly.<div><br></div><div>
<p class="p1"><span class="s1">$ </span>cat /tmp/allowed</p>
<p class="p1"><span class="s1">one</span></p>
<p class="p1"><span class="s1">two</span></p>
<p class="p1"><span class="s1">three</span></p>
<p class="p1"><span class="s1">$ if echo two | grep -Ff /tmp/allowed > /dev/null 2>&1; then echo match; fi</span></p>
<p class="p1"><span class="s1">match</span></p><p class="p1">$ </p></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 3, 2015 at 12:03 PM, Neal Rhodes <span dir="ltr"><<a href="mailto:neal@mnopltd.com" target="_blank">neal@mnopltd.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>
<div>
Exactly how does not assign a list of values separated by pipe to use that variable later on in a script and make a CASE statement happy? <br>
The script below shows a variety of attempts. <br>
<br>
Ultimately, we're aiming to grab the list from a file, eg "LIST="`cat allow.list`"<br>
<br>
<br>
<blockquote>
REMOTE_ADDR=one<br>
<br>
case $REMOTE_ADDR in<br>
one|two|three) echo "I like $REMOTE_ADDR" ;; # Picks this one.<br>
*) echo "I do NOT like $REMOTE_ADDR" ;;<br>
esac<br>
<br>
LIST="one|two|three"<br>
case $REMOTE_ADDR in<br>
$LIST) echo "But now I like $REMOTE_ADDR" ;;<br>
*) echo "But now I do NOT like $REMOTE_ADDR" ;; # Picks this one.<br>
esac<br>
<br>
case $REMOTE_ADDR in<br>
"$LIST") echo "And I like $REMOTE_ADDR" ;;<br>
*) echo "And I do NOT like $REMOTE_ADDR" ;; # Picks this one.<br>
esac<br>
<br>
LIST="one"<br>
case $REMOTE_ADDR in<br>
"$LIST") echo "Yet I like $REMOTE_ADDR" ;; # Picks this one.<br>
*) echo "Yet I do NOT like $REMOTE_ADDR" ;;<br>
esac<br>
<br>
LIST="one\|two\|three"<br>
case $REMOTE_ADDR in<br>
$LIST) echo "However now I like $REMOTE_ADDR" ;;<br>
*) echo "However now I do NOT like $REMOTE_ADDR" ;; # Picks this one.<br>
esac<br>
</blockquote>
<br>
</div>
<br>_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" rel="noreferrer" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" rel="noreferrer" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"> Ed Cashin <<a href="mailto:ecashin@noserose.net" target="_blank">ecashin@noserose.net</a>></div></div>
</div>