【问题标题】:Unix sftp - mput command - transfer all files with a specific prefixUnix sftp - mput 命令 - 传输具有特定前缀的所有文件
【发布时间】:2017-06-16 15:31:09
【问题描述】:

我在一个目录中有一堆文件。但我只想将以ABCXYZ 开头的文件传输到SFTP 服务器。如何在我的 mput 命令中过滤这些?

【问题讨论】:

    标签: unix sftp filenames


    【解决方案1】:

    如果您的文件都在当前目录中:

    sftp user@server << EOF
    cd /destination
    $(for i in ABC* XYZ*; do echo "put $i"; done)
    EOF
    

    输出(示例):

    连接到服务器。 sftp> cd /目标 sftp> 把 ABCfoo.txt 上传 ABCfoo.txt 到 /destination/ABCfoo.txt ABCfoo.txt 100% 0 0.0KB/s 00:00 sftp> 放 XYZfoo.txt 上传 XYZfoo.txt 到 /destination/XYZfoo.txt XYZfoo.txt 100% 0 0.0KB/s 00:00

    【讨论】:

      【解决方案2】:

      只需在sftpput 命令(或mput 别名)中使用文件掩码:

      cd /destination/path
      put ABC*
      put XYZ*
      

      请注意,与常见的命令行 ftp 客户端相反,在 OpenSSH 中 sftp put 本身可以上传多个文件(而 mput 只是 put 的无证别名)。

      【讨论】:

        猜你喜欢
        • 2014-06-02
        • 1970-01-01
        • 2022-10-20
        • 2023-03-16
        • 2011-10-13
        • 2020-06-10
        • 2013-01-18
        • 1970-01-01
        • 2017-04-05
        相关资源
        最近更新 更多