I have 10 files on remote server,I want to continuously check if there is any new file in the remote directory and if there is any new file it should be transferred to the local directory. I could write shell script to get the file but how do I get only the new files to be transferred,new files can be 1 to 10 in number Here is what i tried so far:
#!/bin/bash
user="abc"
ssh_host="host"
from_loc="/tmp/"
to_loc="/tmp/"
file="file.txt"
if ssh $ssh_host test -e $from_loc$file;
then
cd $to_loc
sftp $user@$ssh_host <<EOF
cd $from_loc
get $file
bye
EOF
else echo $file does not exist
fi