1753631 Members
5755 Online
108798 Solutions
New Discussion юеВ

file create

 
SOLVED
Go to solution
Nobody's Hero
Valued Contributor

file create

trying to creat a few thousand small files in a directory to test a process. Itried using split but it has a max number of files it can create.
anyone have a script handy that will create a few thousand small files, like 5k or 1k files?
or even empty files would probably work.
UNIX IS GOOD
6 REPLIES 6
Hein van den Heuvel
Honored Contributor
Solution

Re: file create

perl -e 'for (1 .. shift) { open X,">$_.tmp"; print X $_ . 'x'x1000 }' 2000


You may want to specify how you would like to name your files.


Cheer,
Hein.
James R. Ferguson
Acclaimed Contributor

Re: file create

Hi:

# cat ./touchem
#!/usr/bin/sh
typeset -i i=0
while (( $i < 100 ))
do
touch f${i}
i=$((i+1))
done

...change to the directory in which you want to create the files. Adjust the upper number accordingly.

Regards!

...JRF...
Laurent Menase
Honored Contributor

Re: file create

Hi,
Just a remark,

making thousands of files in the same directory is not very good for perf, it is usually better to hash them to subdirectories
Viktor Balogh
Honored Contributor

Re: file create

wow! 10 years and a day :)

Nobody's Hero
ITRC member since: December 09, 1999
Last contribution date: December 09, 2009

>making thousands of files in the same directory is not very good for perf, it is usually better to hash them to subdirectories

ok, run that touchem' script to a dir called "a", then copy it 10x to have separate dirs :)

****
Unix operates with beer.
Nobody's Hero
Valued Contributor

Re: file create

Yes Viktor, and I still slog through writing scripts as I don't do it often enough. 10 years of medium expertise and trouble shooting with expert backup from you fine folks on this site.

I applaud you women and gentlemen, willing to share your expertise and help us learn something new each and every day. I can't tell you how much help you all have been to me over the years, especially during emergencies.

THANKS * 110,000
UNIX IS GOOD
Viktor Balogh
Honored Contributor

Re: file create

OFF: you can use this link:

http://www.yonkis.com/mediaflash/unmillon.htm

:D (no points for that)
****
Unix operates with beer.