Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create 1000 files that I can use to test a script?

I would like to create 1000+ text files with some text to test a script, how to create this much if text files at a go using shell script or Perl. Please could anyone help me?

like image 999
Karthik Avatar asked Jan 18 '10 09:01

Karthik


2 Answers

#!/bin/bash
seq 1 1000 | split -l 1 -a 3 -d - file

Above will create 1000 files with each file having a number from 1 to 1000. The files will be named from file000 to file999.

like image 91
Damodharan R Avatar answered Oct 18 '22 03:10

Damodharan R


for i in {0001..1000}
do
  echo "some text" > "file_${i}.txt"
done

or if you want to use Python <2.6

for x in range(1000):
    open("file%03d.txt" % x,"w").write("some text")
like image 41
ghostdog74 Avatar answered Oct 18 '22 02:10

ghostdog74