linux系统如何将一个文件同时复制多份
1、创建测试数据 a.txt
[root@linuxprobe test]# seq 10 > a.txt
[root@linuxprobe test]# ls
a.txt
[root@linuxprobe test]# cat a.txt
1
2
3
4
5
6
7
8
9
10
2、利用tee命令将文件同时复制多份 ## 只适用于小文件,因为cat命令要打开文件
[root@linuxprobe test]# cat a.txt | tee dup{1..10}.txt ## 利用tee命令将a.txt复制十份
1
2
3
4
5
6
7
8
9
10
[root@linuxprobe test]# ls
a.txt dup10.txt dup1.txt dup2.txt dup3.txt dup4.txt dup5.txt dup6.txt dup7.txt dup8.txt dup9.txt
[root@linuxprobe test]# md5sum *.txt ## 检测复制结果
3b0332e02daabf31651a5a0d81ba830a a.txt
3b0332e02daabf31651a5a0d81ba830a dup10.txt
3b0332e02daabf31651a5a0d81ba830a dup1.txt
3b0332e02daabf31651a5a0d81ba830a dup2.txt
3b0332e02daabf31651a5a0d81ba830a dup3.txt
3b0332e02daabf31651a5a0d81ba830a dup4.txt
3b0332e02daabf31651a5a0d81ba830a dup5.txt
3b0332e02daabf31651a5a0d81ba830a dup6.txt
3b0332e02daabf31651a5a0d81ba830a dup7.txt
3b0332e02daabf31651a5a0d81ba830a dup8.txt
3b0332e02daabf31651a5a0d81ba830a dup9.txt
3、利用for循环将文件复制多份,适用于大小文件
[root@linuxprobe test]# rm dup* ## 删除上一步测试结果
[root@linuxprobe test]# ls
a.txt
[root@linuxprobe test]# for i in `seq 10`;do cp a.txt cp$i.txt;done ## 利用for循环,将a.txt复制10份
[root@linuxprobe test]# ls
a.txt cp10.txt cp1.txt cp2.txt cp3.txt cp4.txt cp5.txt cp6.txt cp7.txt cp8.txt cp9.txt
[root@linuxprobe test]# md5sum * ## 检测复制结果
3b0332e02daabf31651a5a0d81ba830a a.txt
3b0332e02daabf31651a5a0d81ba830a cp10.txt
3b0332e02daabf31651a5a0d81ba830a cp1.txt
3b0332e02daabf31651a5a0d81ba830a cp2.txt
3b0332e02daabf31651a5a0d81ba830a cp3.txt
3b0332e02daabf31651a5a0d81ba830a cp4.txt
3b0332e02daabf31651a5a0d81ba830a cp5.txt
3b0332e02daabf31651a5a0d81ba830a cp6.txt
3b0332e02daabf31651a5a0d81ba830a cp7.txt
3b0332e02daabf31651a5a0d81ba830a cp8.txt
3b0332e02daabf31651a5a0d81ba830a cp9.txt
4、利用echo 、xargs 命令将文件复制多份
[root@linuxprobe test]# rm cp* ## 删除上一步测试文件
[root@linuxprobe test]# ls
a.txt
[root@linuxprobe test]# echo "cp1.txt cp2.txt cp3.txt cp4.txt" | xargs -n 1 cp a.txt ## 利用echo 、xargs 复制文件多份
[root@linuxprobe test]# ls
a.txt cp1.txt cp2.txt cp3.txt cp4.txt
[root@linuxprobe test]# md5sum * ## 检测复制结果
3b0332e02daabf31651a5a0d81ba830a a.txt
3b0332e02daabf31651a5a0d81ba830a cp1.txt
3b0332e02daabf31651a5a0d81ba830a cp2.txt
3b0332e02daabf31651a5a0d81ba830a cp3.txt
3b0332e02daabf31651a5a0d81ba830a cp4.txt
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了