Quantcast
Channel: How to use OR condition inside tcsh if statement - Stack Overflow
Viewing all articles
Browse latest Browse all 2

How to use OR condition inside tcsh if statement

$
0
0

I am trying to use an OR condition inside an IF statement in tcsh shell. Same statement works in CSH.

Example statement: (cat tesh.sh)

if [ "$1" == "hi" -o "$2" == "hello" ];thenecho hielseecho hellofi

Now if I execute this sample script I get the following errors:

[35] % sh -x test hi hi hello+ test hi hi hellotest[7]: hi: A test command parameter is not valid.+ exit 1[36] % sh -x test hi hi+ test hi hitest[7]: test: Specify a parameter with this command.+ exit 1[37] % sh -x test hi hello+ test hi hellotest[7]: test: Specify a parameter with this command.+ exit 1[38] % sh -x test hi hello+ test hi hellotest[7]: test: Specify a parameter with this command.+ exit 1[39] %

Please suggest what can be done?

Additional Info:

[44] % uname -sHP-UX[45] %[45] % echo $SHELL/bin/tcsh[46] %

More example:

 cat new_test.txtif ([ $1 == 1 ] || [ $2 == 1 ])thenecho $1 and $2fi./new_test.txt 1 1./new_test.txt: ==: A test command parameter is not valid../new_test.txt: ==: A test command parameter is not valid.

More Example:

 cat suggested.shif (($1 == 1) || ($2 == 1)) ; then echo "$1 and $2" ; fi ./suggested.sh 1 1./suggested.sh: 1:  not found../suggested.sh: 1:  not found.

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images