Friday, 8 December 2023

Retrieve multiple files from sftp

I wanted to get GLEAM data from an sftp server. sftp doesn't seem to support wildcards with the get command, so instead I used a script:

for YYYY in 2015 2014 2013 2012 2011 2010 2009 2008 2007 2006 2005; do
  sshpass -p password sftp -P 2225 username@hydras.ugent.be:/data/v3.8a/daily/${YYYY} << EOF
  get E_${YYYY}_GLEAM_v3.8a.nc
  exit
  EOF
done