0

I'm actually trying to get all files beginning with the current date from another server with SFTP. Nevertheless, * does not work in SFTP so I don't see how I can do...

Here is the batch I've done so far:

#!/bin/sh
today=$(date +%Y%m%d)
lftp<<END_SCRIPT
open sftp://name@server
get $today*
bye
END_SCRIPT

@Martin Prikryl

Thank you, it works fine now. I've search a bit before you answered and I've found this (a lot less efficient^^):

today=$(date +%Y%m%d)
var=`echo `echo ls -1 | sftp name@domain:dir1/subdir` | sed -n 's/ /\n/gp'|sed -n '/^$today/p'`
lftp<<END_SCRIPT
open sftp://name@server
get $var
bye
END_SCRIPT
Faquarl
  • 158
  • 1
  • 9

1 Answers1

2

Use the mget instead of the get.

See https://lftp.yar.ru/lftp-man.html

get
...
Does not expand wildcards, use mget for that.
...
mget
...
Gets selected files with expanded wildcards.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992