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 ...
- The only way to upload files is using
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