bash 如何使用命令行 FTP 上传多个文件和目录?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10642092/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to upload multiple files and directories using command line FTP?
提问by Tapefreak
Possible Duplicate:
How do you recursively ftp a folder in linux
可能的重复:
你如何递归 ftp linux 中的文件夹
I'd like to simply upload a directory and all of its contents, recursively, from the command line. To do this from the command line would be so much easier than resorting to FileZilla or some other windowed app.
我想简单地从命令行上传一个目录及其所有内容,递归。从命令行执行此操作比求助于 FileZilla 或其他一些窗口应用程序要容易得多。
My workaround for this has been to zip, then upload the zip w/FTP, then SSH and unzip...
我对此的解决方法是压缩,然后使用 FTP 上传 zip,然后 SSH 并解压缩...
Is there a way using the BASH command line ftp to upload multiple files and directories?
有没有办法使用BASH命令行ftp上传多个文件和目录?
Looking at the available commands there is only put and send which allow only a single file and no directory.
查看可用命令,只有 put 和 send 只允许单个文件而没有目录。
回答by Michael
If you have access to SSH, can you also use scp? If so, try something like:
如果可以访问SSH,是否也可以使用scp?如果是这样,请尝试以下操作:
scp -r local_dir you@server:remote_dir
The -r flag allows you to recursively copy to your destination.
-r 标志允许您递归复制到您的目的地。
回答by glenn Hymanman
Here's a technique that doesn't use ftp, since you already have ssh access:
这是一种不使用 ftp 的技术,因为您已经拥有 ssh 访问权限:
tar czf - [your files here] | ssh user@host 'cd /dir && tar xzf -'
Create a tar file on stdout, and pipe to ssh where it will untar from stdin.
在标准输出上创建一个 tar 文件,并通过管道连接到 ssh,它将从标准输入解压缩。

