The C shell (csh) doesn't have the variable $#
. In fact, in csh the arguments passing, if
statement etc are fundamentally different to say, ksh or bash. All your code looks like a bash code but your shebang line contains csh
. So if you want to use bash
then change it to:
#!/bin/bash
if [[ $# != 1 || $1 != "first" && $1 != "second" ]]
then
echo "Error: Usage: $0 [first|second]"
exit 1
fi
Or if you really wanted to use csh
then you have re-write the code to:
#!/bin/csh
if ( $#argv != 1 || $1 != "first" && $1 != "second" ) then
echo "Error: Usage: $0 [first|second]"
exit 1
endif