I have a set of variables that have a date stored, e.g.
today=$(date '+%Y-%m-%d')
yesterday=$(date -d "yesterday 13:00" '+%Y-%m-%d')
day2=$(date -d "2 days ago 13:00" '+%Y-%m-%d')
they are stored in an array
DAYS=($day2 $yesterday $today)
now I want to loop over all the days in the array and for each day I want to have a temporary variable with the date on day before:
for i in "${DAYS[@]}"
do
j=should be date of i minus 1 day (1 day before date of i)
done
How do I subtract one day (or for that matter any other amount of time) from a date that's stored in a variable?
Thanks, Patrick