Reputation: 12865
I'm writing a shell script and trying to check whether two files exists. Here is the script example:
#!/bin/bash
if [[ [ -e File1Name ] -a [ -e File2Name ] ]]
then
echo Yes
el
echo No
fi
and get
script: line 5: conditional binary operator expected
script: line 5: syntax error near `-e'
script: line 5: `if [[ [ -e CA ] -a [ -e CA-draw ] ]]'
What is wrong with my script and hot to fix it?
Upvotes: 2
Views: 7124
Reputation: 4384
if [ -e File1Name -a -e File2Name ]
then
echo Yes
else
echo No
fi
Upvotes: 3
Reputation: 798686
Both [[
and [
are commands; you need to pick one of them, and use only it with if
.
Upvotes: 1