I need to execute the following shell script in my macOS terminal. The loop never executes more than its first iteration.
function execute_function() {
# Launch job
number_of_jobs=$1
echo "Launching ${number_of_jobs} jobs"
for i in {1..$1}; do
job_id=`head /dev/urandom | tr -dc A-Z0-9 | head -c 6 ; echo ''`
echo "Launching Job: $job_id"
echo $i
done
}
When I run it, I always get:
execute_function 10
Launching 10 jobs
Launching Job: XX9BWC
{1..10}
The same happens if I replace: $1
with $number_of_jobs
or "${number_of_jobs}"