subtract days from a date in bash
You are specifying the date incorrectly. Instead, say:
date --date="${dataset_date} -${date_diff} day" +%Y-%m-%d
If you need to store it in a variable, use $(...)
:
p_dataset_date=$(date --date="${dataset_date} -${date_diff} day" +%Y-%m-%d)
one liner for mac os x:
yesterday=$(date -d "$date -1 days" +"%Y%m%d")
If you're not on linux, maybe mac or somewhere else, this wont work. you could check with this:
yesterday=$(date -v-1d +"%Y-%m-%d")
to get more details, you could also see
man date