I want to subtract \"number of days\" from a date in bash. I am trying something like this ..
echo $dataset_date #output is 2013-08-07 echo $date_diff #outp
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)