Reputation: 158
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
Upvotes: 0
Views: 3775
Reputation: 202534
Use the mget
instead of the get
.
See https://lftp.yar.ru/lftp-man.html
get
...
Does not expand wildcards, usemget
for that.
...
mget
...
Gets selected files with expanded wildcards.
Upvotes: 2