Bash, test for presence of two files -


i found this answer works fine, wanted understand why following code won't detect presence of 2 files?

if [[ $(test -e ./file1 && test -e ./file2) ]];   echo "yep" else   echo "nope" fi 

running directly shell works expected:

test -e ./file1 && test -e ./file2 && echo yes 

the output of test -e ./file1 && test -e ./file2 empty string, causes [[ ]] produce non-zero exit code. want

if [[ -e ./file1 && -e ./file2 ]];     echo "yep" else     echo "nope" fi 

[[ ... ]] replacement [ ... ] or test ..., not wrapper around it.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

php - Dynamic url re-writing using htaccess -

java - Multi-Label Document Classification -