Linux批量创建多个文件
1、批量创建文件
bash
root@DESKTOP-OV4EGIC:~/test# touch {1..100}.txt
root@DESKTOP-OV4EGIC:~/test# ls
1.txt 15.txt 21.txt 28.txt 34.txt 40.txt 47.txt 53.txt 6.txt 66.txt 72.txt 79.txt 85.txt 91.txt 98.txt
10.txt 16.txt 22.txt 29.txt 35.txt 41.txt 48.txt 54.txt 60.txt 67.txt 73.txt 8.txt 86.txt 92.txt 99.txt
100.txt 17.txt 23.txt 3.txt 36.txt 42.txt 49.txt 55.txt 61.txt 68.txt 74.txt 80.txt 87.txt 93.txt
11.txt 18.txt 24.txt 30.txt 37.txt 43.txt 5.txt 56.txt 62.txt 69.txt 75.txt 81.txt 88.txt 94.txt
12.txt 19.txt 25.txt 31.txt 38.txt 44.txt 50.txt 57.txt 63.txt 7.txt 76.txt 82.txt 89.txt 95.txt
13.txt 2.txt 26.txt 32.txt 39.txt 45.txt 51.txt 58.txt 64.txt 70.txt 77.txt 83.txt 9.txt 96.txt
14.txt 20.txt 27.txt 33.txt 4.txt 46.txt 52.txt 59.txt 65.txt 71.txt 78.txt 84.txt 90.txt 97.txt
2、批量创建目录
bash
root@DESKTOP-OV4EGIC:~/test# mkdir {1..100}.txt
root@DESKTOP-OV4EGIC:~/test# ls
1.txt 15.txt 21.txt 28.txt 34.txt 40.txt 47.txt 53.txt 6.txt 66.txt 72.txt 79.txt 85.txt 91.txt 98.txt
10.txt 16.txt 22.txt 29.txt 35.txt 41.txt 48.txt 54.txt 60.txt 67.txt 73.txt 8.txt 86.txt 92.txt 99.txt
100.txt 17.txt 23.txt 3.txt 36.txt 42.txt 49.txt 55.txt 61.txt 68.txt 74.txt 80.txt 87.txt 93.txt
11.txt 18.txt 24.txt 30.txt 37.txt 43.txt 5.txt 56.txt 62.txt 69.txt 75.txt 81.txt 88.txt 94.txt
12.txt 19.txt 25.txt 31.txt 38.txt 44.txt 50.txt 57.txt 63.txt 7.txt 76.txt 82.txt 89.txt 95.txt
13.txt 2.txt 26.txt 32.txt 39.txt 45.txt 51.txt 58.txt 64.txt 70.txt 77.txt 83.txt 9.txt 96.txt
14.txt 20.txt 27.txt 33.txt 4.txt 46.txt 52.txt 59.txt 65.txt 71.txt 78.txt 84.txt 90.txt 97.txt
3、文件批量重命名
替换文件名.bak
为空
bash
root@DESKTOP-OV4EGIC:~/test# touch {1..10}.txt.bak
root@DESKTOP-OV4EGIC:~/test# ls
1.txt.bak 10.txt.bak 2.txt.bak 3.txt.bak 4.txt.bak 5.txt.bak 6.txt.bak 7.txt.bak 8.txt.bak 9.txt.bak
root@DESKTOP-OV4EGIC:~/test# rename s/\.bak// *
root@DESKTOP-OV4EGIC:~/test# ls
1.txt 10.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt
root@DESKTOP-OV4EGIC:~/test#