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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM