I am pretty sure this has been asked already in some form, I just cannot come up with a good find to search it.
I want to have a script that do things N times and to which I can pass as a variable what command to issue N times. In general the command might use the iterator value to change something. For instance I would like to do something like
~> doNtimes.sh 10 0 "ls *$(($2 + $i ))*.gnu | wc -l;"
where doNtime.sh is something like
for ((i=0; i < $1; ++i)); do
echo "iterator=$i";
$3
done
of course the current use of double quotes make me fail. I have tried with single quotes but does not work either (although for a different reason). The fact that I have variable with spaces and contains variable to be evaluated in the script makes impossible for me to find the right syntax ... any idea?