#! /bin/bash
if [ !\(-f new.bash -o -d new.bash\) ]
then
echo "Neither"
else
echo "yes"
fi
it works but leaves an error:
/file_exist_or_not.bash
./file_exist_or_not.bash: line 3: [: too many arguments
yes
BTW, Why the inner parenthesises needs to be escaped?
Bash uses spaces to separate tokens, which are then passed as arguments to the commands (in this case the command is
test). See the man page fortestfor more details.To solve, you need to add spaces between the operands.