我想用一些文本创建 1000 多个文本文件来测试脚本,如何使用 shell 脚本或 Perl 一次性创建这么多文本文件。请问有人能帮帮我吗?
最佳答案
for i in {0001..1000}
do
echo "some text" > "file_${i}.txt"
done
或者如果你想使用 Python <2.6
for x in range(1000):
open("file%03d.txt" % x,"w").write("some text")
关于python - 如何创建 1000 个可用于测试脚本的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2084832/