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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -