Verifying if a file exist (script shell)

Hello,

This is my code:

nb_lignes=`wc -l $1 | cut -d " " -f1`
 for i in $(seq $(($nb_lignes - 1)) )
 do
 machine=`head $1 -n $i | tail -1`
 machine1=`head $1 -n $nb_lignes | tail -1`
 ssh  root@$machine -x " scp /home/file.txt root@$machine1:/home && rm -r /home/file.txt"
 done
 fi

I'd like to verify if file.txt exist in such machine before the scp et rm ,Please i ask how can i modify this script ?

Thank you.

Hi ,
You can do that using

if [ -f file.txt ]; then

Regards,
Haris

Did you mean ?!

ssh  root@$machine -x " if [ -f file.txt ] scp /home/file.txt root@$machine1:/home && rm -r /home/file.txt"