我们经常会需要在linux shell中执行文件/文件夹的传输操作。此时,使用ftp是个不错的选择。推荐使用ncftp。
- 安装ncftp
sudo apt-get install ncftp
- 上传/下载
上传:ncftpput -R -u username -p password -P port remote_dir local_dir
下载:ncftpget -R -u username -p password remote_dirlocal_dir
下载文件夹到本地的话,会包含远程目录的全路径。如果想下载后自动去除上级目录,可以使用wget。
wget -r -nH -nc --cut-dirs=number ftp://user:password@servername/remote/dir/path/* local_dir
* -nH avoids the creation of a directory named after the server name
*