新的脚本。如何编写
代码来创建多个
文件(a.txt,b.txt,…,z.txt)?
谢谢。
一个命令创建26个空
文件:
touch {a..z}.txt
或152:
touch {{a..z},{A..Z},{0..99}}.txt
一个小循环创建152个文件与一些内容:
for f in {a..z} {A..Z} {0..99}
do
echo hello > "$f.txt"
done
您可以使用前导零编辑文件:
for i in {0..100}
do
echo hello > "File$(printf "%03d" "$i").txt"
done
或者在Bash 4中:
for i in {000..100}
do
echo hello > "File${i}.txt"
done