I'm trying to do a number of test runs on an algorithm and as such have a number of directories containing exactly the same data (subdirectories and files) to be run on a cluster. I would like all of these directories to contain a file called randomseed.txt
which contains a unique integer. Currently, the randomseed files exist, but contain the same integer: 1. Is there a bash script I could use, or a variation of find
that I could use to achieve this simply?
My idea was something like this:
#!/bin/bash
declare -i VAR
VAR=1
find . -type f -name "randomseed.txt" -execdir VAR=$VAR+1 | $VAR > randomseed.txt \;
echo $VAR
echo done
but I'm not entirely sure how or if I can do something like this with -exec
or -execdir
.