I am trying to use OR condition inside an IF statement in tcsh shell. Same statement works fine in CSH but not working on TCSH. I have not much exposer to TCSH and need some clarity why it is not working.
Example statement: (cat tesh.sh)
if [ "$1" == "hi" -o "$2" == "hello" ];then
echo hi
else
echo hello
fi
Now if I execute this sample script I get following errors:
[35] % sh -x test hi hi hello
+ test hi hi hello
test[7]: hi: A test command parameter is not valid.
+ exit 1
[36] % sh -x test hi hi
+ test hi hi
test[7]: test: Specify a parameter with this command.
+ exit 1
[37] % sh -x test hi hello
+ test hi hello
test[7]: test: Specify a parameter with this command.
+ exit 1
[38] % sh -x test hi hello
+ test hi hello
test[7]: test: Specify a parameter with this command.
+ exit 1
[39] %
Please suggest what can be done?
Additional Info:
[44] % uname -s
HP-UX
[45] %
[45] % echo $SHELL
/bin/tcsh
[46] %
More example:
cat new_test.txt
if ([ $1 == 1 ] || [ $2 == 1 ])
then
echo $1 and $2
fi
./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.
PS: IF you do down vote then , please let me know the reason. I will try to fix it before coming to this forum.
Aucun commentaire:
Enregistrer un commentaire