0

shell script that includes a message that says how many days are left in a semester. (script to subtract a future date from a current date) Please how do you write this script out?

so far i have:

date -d '12/7/20' +%j

342 <- that was the output

however, I am trying to subtract a future date from the current date '12/7/20'

RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93

1 Answers1

0

this should do the job:

A="2020-10-14"
B="2021-02-22"
echo $(( ($(date -d $B +%s) - $(date -d $A +%s)) / 86400 )) days between
spawnTREx
  • 11
  • 1