The following bash script won't work. I need to calculate the date depending on the number of days since 14th Oct 1582, where the argument will be the number of days.

date -d '14 Oct 1582 + "$d" days'

for example the command

./datedays.sh 154748

should give

Wed Jun 21 00:00:00 BST 2006

instead it give an error

date: invalid date ‘14 Oct 1582 + "$d" days’

2 Answers 2


You must use double quotes instead of single quote:

date -d "14 Oct 1582 + $d days"

You are using strong quoting(single quoting) in the script as strong quoting prevents the interpretation of contents inside the single quote except the quote.

Single quoting turns off the special meaning of $ in a script.

echo "$PATH"


echo '$PATH'

Not Works! Output remains same as input

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.