Tuesday, April 16, 2013

Generate some files in folders for testing using bash.

I wanted a small test data set consisting of some files in folders, heres a quick shell snippet to generate some:

for dir in {1..100}; do
for dir2 in {a..f}; do
folder=dir-${dir}/dir-${dir2}; mkdir -p ${folder}
echo "A file with some text" > $folder/`pwgen -A10`.txt

Every time you run it you get more files, but the folders remain the same. It needs bash 3 or greater to run and creates folder like:


No comments: