Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command test in shell with or 1

Status
Not open for further replies.

loloman

Technical User
Oct 30, 2002
16
0
0
FR
Hi, how can i write in shell that :
If VAR # "valeur" or VAR # "valeur1" or VAR # "valeur2"
then
....
fi
 
Assuming # stands for different:
if [ "$VAR" != "valeur" -o "$VAR" != "valeur1" -o "$VAR" != "valeur2" ]
then
echo "Test passed"
else
echo "Test failed"
fi

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
PHV, I think you have a logic error. The result would be "Test Passed" for any value of $VAR.
 
pat.sh valuer
pat.sh valuer3
pat.sh valuer999
pat.sh valuerA

pat.sh:
Code:
#!/bin/ksh

a="$1"

if [[ "$a" = valuer*([0-9]) ]] ; then
   echo "[$a] - FOUND"
else
   echo "[$a] - NOT found"
fi;

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Ygor,
If VAR # "valeur" or VAR # "valeur1" or VAR # "valeur2"

I just translated the request.[blush]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top