Nic*_*ers 5 linux ftp command-line
我有一个远程服务器上文件的(几千个)绝对路径列表,我需要将其下载到我的 PC 上。
我还需要这些文件来保持这些文件的目录结构完整。
例子:
/* UNIX Server File-System */
/home/username/
stuff/
more-stuff/
data/
file1.txt
/* Local Windows File-System After Transfer */
C:\Users\username\Documents\home\username\
stuff\
more-stuff\
data\
file1.txt
Run Code Online (Sandbox Code Playgroud)
理想情况下,我会使用某种类型的 FTP 将这些文件传送到我的 PC。但是,我不知道支持获取文件列表的程序或 CLI 命令。我需要从特定目录中获取特定文件,我不能只下载整个目录。
我的问题:如何使用绝对路径列表自动将文件下载到我的本地主机?(同时保持目录结构完整)
此外,我将这些文件放在一个 PHP 数组中。所以我可以将列表导出为 JSON、CSV、XML 等。
wget
具有您正在寻找的功能。从联机帮助页:
-i file
--input-file=file
Read URLs from a local or external file. If - is specified as file, URLs are read from the standard input. (Use ./- to read from a file literally named -.)
Run Code Online (Sandbox Code Playgroud)
换句话说:wget -i filelist.txt
。
filelist 也不一定必须是 txt,因为 wget 通过--force-html
开关支持 html 。如果您拥有的只是目录/文件列表,则可以在命令行上使用--base
开关设置基本 URL 。
如果你介意你可以使用rsync
类似的东西
rsync -av --files-from=/path/yourlist.txt / remote:/backup\n
Run Code Online (Sandbox Code Playgroud)\n\n在哪里
\n\n/path/yourlist.txt
您可以将文件列表与完整路径放在一起/
添加到列表中文件名的路径(如果它们是完整路径名/
)remote:/backup
远程主机名及其相对路径您可以--files-from
从man rsync
[ 1 ]中阅读更多搜索内容
\n\n\n--files-from=文件
\n\nRun Code Online (Sandbox Code Playgroud)\n\nUsing this option allows you to specify the exact list of files to transfer (as\nread from the specified FILE or - for standard input). It also tweaks the \ndefault behavior of rsync to make transferring just the specified files and \ndirectories easier:\n
\n
\n- 隐含了 --relative (-R) 选项,它保留为文件中的每个项目指定的路径信息(如果要关闭该选项,请使用 --no-relative 或 --no-R)。
\n- --dirs (-d) 选项是隐含的,它将创建目标列表中指定的目录,而不是吵闹地跳过它们(如果要关闭它,请使用 --no-dirs 或 --no-d )。
\n- --archive (-a) 选项\xe2\x80\x99s 行为并不意味着 --recursive (-r),因此如果需要,请明确指定它。
\n- 这些副作用会更改 rsync 的默认状态,因此命令行上 --files-from 选项的位置与其他选项的解析方式无关(例如 -a 在之前或之后的工作方式相同\n -- files-from,就像 --no-R 和所有其他选项一样)。
\n
...在手册页中有更多...
\n 归档时间: |
|
查看次数: |
1851 次 |
最近记录: |