Getting date of X days ago in bash script, using argument variable

It works if ‘ is replaced with ” into this command on the script –

STAMP=`date --date="$1 day ago" +%y%m%d`

The clue was the two different character ` and ‘ used in the error response –

date: invalid date `$1 day ago'

An expert in bash scripting (not me) can probably explain why this has happen.

Leave a Comment