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
分类:
(01)linux
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!