I am trying to download a bunch of files from a sftp server. The organization of the server is the following: there is a folder per year, and each yearly folder, there is a folder per day. In each day, there are 8 files ending in .nc
that I want to download. The names of the files themselves are too crazy to keep track of. I have tried a few different approaches but I have not been successful in giving get
the right instructions to get the files.
My current version is to have a loop before connecting to the sftp so I can write the name and then connect to the sftp and download that file:
for i in `seq 1 1 366`;
do
if [ $i -lt 10 ]; then
today='00$i/*.nc'
elif [ $i -ge 10 ] && [ $i -lt 100 ]; then
today= '0$i/*.nc'
elif [ $i -ge 100 ]; then
today= '$i/*.nc'
fi
done
sshpass -p $(cat ~/Code/sftp_passwd.txt) sftp cgerlein@cygnss-sftp-1.engin.umich.edu <<EOF
cd ..
cd ..
cd /data/cygnss/products/CDR/l1/2019/
get $today /scratch/myfolder/
quit
EOF
I don't think get
is liking the wildcard in there. And this might not even be the best approach. Any suggestions? Thanks!