Operating System - HP-UX
1753507 Members
5057 Online
108795 Solutions
New Discussion юеВ

Re: trouble with "||" operand

 
SOLVED
Go to solution
Dennis Handly
Acclaimed Contributor

Re: trouble with "||" operand

>O'Kevin: Which shell are you using?

Chris is obviously using a real shell and not the scummy C shell.

>Aashique: your pattern hdisk[0-9]* will not work in if condition.

Why not? Pattern matching will work in [[ ]].
Aashique
Honored Contributor

Re: trouble with "||" operand

Hi,
I check this way and its running.
$ more test
ANS=vpath02
a=`echo $ANS|awk '/hdisk[0-9]/ {print $0}'`
b=`echo $ANS|awk '/vpath[0-9]/ {print $0}'`

if [ $a ] || [ $b ]
then
echo " YES"
else
echo "NO"
fi
$ ./test
YES
lawrenzo_1
Super Advisor

Re: trouble with "||" operand

just back from lunch

Ok thanks all,

I'll give take a look at these suggestions and let you know ...
hello
lawrenzo_1
Super Advisor

Re: trouble with "||" operand

thanks all for the help and suggestions - Dennis gave the best solution for the korn shell!

#!/bin/ksh

print "Please enter a hdisk or vpath you would like to check and potentially remove: \c"

while true
do

read ANS

if [[ $ANS = hdisk[0-9]* || $ANS = vpath[0-9]* ]] ; then

break
print "incorrect selection please enter a valid hdisk or vpath: \c"

else

print "incorrect selection please enter a valid hdisk or vpath: \c"

fi
done

echo $ANS
hello
Yogeeraj_1
Honored Contributor

Re: trouble with "||" operand

hi chris,

have a look the following url:
http://www.injunea.demon.co.uk/pages/page205.htm

should look something like:
if [ $ANS != hdisk[0-9]* ] || [ $ANS != vpath[0-9]* ]
then
..

(unfortunately, i do not have any machine at hand to validate this right now!)

The [[ ]] are not properly stated.

hope this helps!

kind regards
yogeeraj

No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Dennis Handly
Acclaimed Contributor

Re: trouble with "||" operand

>Yogeeraj: have a look the following URL:
http://www.injunea.demon.co.uk/pages/page205.htm

This appears to be Borne shell document, not ksh or posix.
http://docs.hp.com/en/B2355-60130/sh-posix.1.html
http://docs.hp.com/en/B2355-60130/ksh.1.html