MiloBellano
MiloBellano

Reputation: 396

Importing .sql file into MongoDB, iterating this action 1000 times

I need to do several test with a large file in mongoDB. But my test data is in .sql format and only of 2MB.

I need a way to generate a 2GB input file and I thought two ways:

I don't know in which OS MongoDB will run, so a multiplatform solution is preferred. Which way is better?

Thanks.

Upvotes: 1

Views: 79

Answers (1)

Antonio Ragagnin
Antonio Ragagnin

Reputation: 2327

The following script, read inputfile.txt and append it into outputfile.txt until it reach a size of 2GB.

 filename_in="inputfile.txt"  
 filename_out="outputfile.txt" 
 size="2000000000"       #2GB
 echo > $filename_out
 while [  $(stat -c%s "$filename_out") -lt "$size" ]; do
      echo file size =  $(stat -c%s "$filename_out")
      cat $filename_in >> $filename_out
done

Upvotes: 1

Related Questions