Create multiple files in shell script

I wanted to test subversion with multiple files for its stability.

Multiple files means, really multiple. yes. I wanted to test with 100K files. 1,00,000 files in a directory.

searched for a shell script and wanted to ask in ilugc mailing list.
Then, I asked there.

Here is the discussion.
http://www.ae.iitm.ac.in/pipermail/ilugc/2009-August/049837.html

The discussion went with some ideas and psuedo-code for shell script.

Atlast, I wrote it.

Here is the script “create_files.sh”

##########################################
#!/bin/bash
# This script is used to copy a single file to number of copies

# How to execute?

#./create_files.sh <file_to_copy> <No of copies required>

# Example
# ./create_files.sh test.txt 10

# $1 is the first argument i.e the filename
# $2 is the second argument i.e no of copies required.

files_count=$2
for i in `seq 1 $files_count`
do
cp $1 $1.$i
done
#########################################

Wow, using this script, I created some 10,000 files and tested svn for its stability.
svn also rocks with this huge no of files.

Long live Open Source utilities.

One thought on “Create multiple files in shell script

  1. of course like your web site but you have to test the spelling on quite a few of your posts.
    A number of them are rife with spelling problems and I in finding it very bothersome to inform the reality
    nevertheless I’ll definitely come again again.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s