bash – 使用shell创建多个包含内容的文件

新的脚本。如何编写代码来创建多个文件(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

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...