I would like to check if both files exist, but I am getting
test.sh: line 3: [: missing `]\'
Can anyone see what\'s wrong?
#!/b
if [ -e .ssh/id_rsa -a -e .ssh/id_rsa.pub ]; then
echo "both exist"
else
echo "one or more is missing"
fi
Here,
-e check only the file is exits or not.If exits,it return true.else,it return false.
-f also do the same thing but,it check whether the given file is regular file or not.based on that it return the true/false.
Then you are using &&.So that,It need two [[ .. ]] brackets to execute.
instead you can use the -a [same as && operator] -o [same as || operator]. If you need more information go through this link
http://linux.die.net/man/1/bash.