I'd like to put files from result of !find command from lftp.
I tried:
$> lftp -u foo, sftp://bar
lftp foo@bar$> put < !find ./local -type f
But failed!!
This worked:
$> lftp -u foo, sftp://bar
lftp foo@bar$> !find ./local -type f | awk '{print "put "$1}' > /tmp/files.lftp
lftp foo@bar$> source /tmp/files.lftp
Is there another way!? I'd like to use stdio redirects (pipes, stdin...).
I have read through the whole man lftp(1) and it seems that the way you have chosen is actually the best one.
!
command doesn't support direct combination with another commands, as you tried put < !find ...
put
, mput
or mirror
. mirror
is of no use for you as you noted, because it preserves the path. put
or mput
commands don't support any means to specify a file with list of files to upload.So, the only possibility is what you have: generate the script and use source
to run it.
What you could try is to put all the files into one mput
command:
!find ./local -type f | awk -v ORS=" " 'BEGIN{print "mput "}{print}' > /tmp/files.lftp
but be careful: although I haven't found it in the docs, there might be limitation for maximum line size! So I think in the end your way is the best way to go.
Note that you can also code-golf your command to:
!find ./local -type f -printf "put %p\n" > /tmp/files.lftp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With