Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.4k
  • 205
  • 1.8k
  • 2.3k
Source Link

Can't use argument in bash date calculation script

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.

d="$1"
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’