Assuming you are using scp and ssh for remote connections, something like this should do what you want.
declare -a array1=(' user1@user1.user.com '); for i in "${array1[@]}"; do if ssh -q "$i" "test -f /home/user/directory/file"; then scp "$i:/home/user/directory/file" /local/path else echo 'Could not access remote file.' fi done
Alternatively, if you don’t have to care about the difference between a deleted file that does not exist and other possible scp errors, then the following will work.
declare -a array1=(' user1@user1.user.com '); for i in "${array1[@]}"; do if ! scp "$i:/home/user/directory/file" /local/path; then echo 'Remote file did not exist.' fi done
source share