zoukankan      html  css  js  c++  java
  • sftp,get命令使用*通配符的方式获取批量的文件

    需求描述:

      今天在使用sftp进行get文件的时候,有很多文件名类似的文件,以为还是需要一个一个get

      后来发现get也可以使用通配符的方式进行匹配获取多个文件,在此记录下

    操作过程:

    1.通过sftp连接到目标主机,切换到具体目录下

    [root@redhat6 ~]# sftp oracle@192.168.53.12
    Connecting to 192.168.53.12...
    oracle@192.168.53.12's password: 
    sftp> ls
    check_ps_if_exits.sh                           mysql-5.7.19-linux-glibc2.12-x86_64            mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz     test                                           
    sftp> cd test
    sftp> ls
    201800400109.txt   2018004003.txt     201800401.txt      20180040102.txt    201800409.txt      
    sftp> ls -l
    -rw-r--r--    1 oracle   oinstall        0 Apr  9 09:36 201800400109.txt
    -rw-r--r--    1 oracle   oinstall        0 Apr  9 09:36 2018004003.txt
    -rw-r--r--    1 oracle   oinstall        0 Apr  9 09:36 201800401.txt
    -rw-r--r--    1 oracle   oinstall        0 Apr  9 09:36 20180040102.txt
    -rw-r--r--    1 oracle   oinstall        0 Apr  9 09:36 201800409.txt
    sftp> 

    备注:发现这些文件都是2018004开头的文件.把这些文件都下载到本地.

    2.通过*通配符的方式获取多个文件

    sftp> get 2018004*
    Fetching /home/oracle/test/201800400109.txt to 201800400109.txt
    Fetching /home/oracle/test/2018004003.txt to 2018004003.txt
    Fetching /home/oracle/test/201800401.txt to 201800401.txt
    Fetching /home/oracle/test/20180040102.txt to 20180040102.txt
    Fetching /home/oracle/test/201800409.txt to 201800409.txt
    sftp> 

    备注:通过使用星的方式,能够匹配到的文件都下载到了本地.

    3.查看本地已经下载的文件

    sftp> exit
    [root@redhat6 ~]# ls -l
    total 4
    -rw-r--r-- 1 root root    0 Apr  9 09:41 201800400109.txt
    -rw-r--r-- 1 root root    0 Apr  9 09:41 2018004003.txt
    -rw-r--r-- 1 root root    0 Apr  9 09:41 20180040102.txt
    -rw-r--r-- 1 root root    0 Apr  9 09:41 201800401.txt
    -rw-r--r-- 1 root root    0 Apr  9 09:41 201800409.txt
    drwxr-xr-x 7 root root 4096 Mar 30 14:54 workspace

    备注:退出sftp程序之后,已经可以看到多个通过*匹配的文件已经下载到了本地.

    文档创建时间:2018年4月9日09:43:47

  • 相关阅读:
    arm64 boot
    python学习笔记
    字符编码问题详解
    Restful 架构设计
    调度器学习总结
    从0开始学习maven搭建spring+mybatis框架
    java内存管理
    linux 基础
    自学有感
    echart 图表显示技术
  • 原文地址:https://www.cnblogs.com/chuanzhang053/p/8757556.html
Copyright © 2011-2022 走看看