Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
344 views
in Technique[技术] by (71.8m points)

linux如何批量创建多个指令逻辑内容档案?

linux如何批量创建多个指令逻辑内容档案?

我期望

somefunction {1..3}.txt --内容="{3} test"

系统会建立 1.txt,2.txt,3.txt
内容分别是 1 test,2 test,3 test

目前我的知识1 :
可以使用 touch {起始..结束}.txt 批量创建档案

test@test:~$ touch {1..10}.txt
test@test:~$ ls
10.txt  1.txt  2.txt  3.txt  4.txt  5.txt  6.txt  7.txt  8.txt  9.txt

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

for 循环可实现,如

for i in {1..3}; do echo "$i test" > "$i.txt"; done

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...