I have such bash script:
array=( \'2015-01-01\', \'2015-01-02\' )
for i in \"${array[@]}\"
do
python /home/user/executeJobs.py {i} &> /home/user/
I had the same issue and I tried some of the above answers, maybe they are ok, but none of those answers fixed on what I was trying to do, using macOS.
I was trying to iterate over dates in the past, and the following is what worked for me:
#!/bin/bash
# Get the machine date
newDate=$(date '+%m-%d-%y')
# Set a counter variable
counter=1
# Increase the counter to get back in time
while [ "$newDate" != 06-01-18 ]; do
echo $newDate
newDate=$(date -v -${counter}d '+%m-%d-%y')
counter=$((counter + 1))
done
Hope it helps.