When I parameterize the date in the code as :
str_last_log_date="2017-07-24"
last_log_date=$(date -d '${str_last_log_date}' +%s)
threshold_days_ago=$(date -d 'now - 2 days' +%s)
echo "last_log_date ${last_log_date} thres_days_ago ${threshold_days_ago}"
Gives the error :
date: invalid date ‘${str_last_log_date}’ last_log_date thres_days_ago 1500969455
But if I don't parameterize the date and pass directly, it gives the correct result :
last_log_date=$(date -d '2017-07-24' +%s)
threshold_days_ago=$(date -d 'now - 2 days' +%s)
echo "last_log_date ${last_log_date} thres_days_ago ${threshold_days_ago}"
last_log_date 1500854400 thres_days_ago 1500969511
Any tips?
$IFS
is modified to include-
or:
or digits... – Stéphane Chazelas Jul 27 '17 at 11:21