7

I have a requirement to add 10 days to current date and assign it to a variable. But I am getting error:

date: illegal option -- d

This is what I tried:

$> NEW_expration_DATE=$(date -d "+10 days")

Result:

date: illegal option -- d
Usage: date [-u] [+Field Descriptors]
Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
Rajesh Renke
  • 87
  • 1
  • 1
  • 7

3 Answers3

11

Try this: NEW_expration_DATE=$(gdate -d "+10 days")

venki
  • 127
  • 1
  • 3
0

It looks like you are using a POSIX shell, and that there is no way to do simple date arithmetic in here.

I found a guy who explains it and who coded something to substract dates. You may be able to adapt it for your case: https://unix.stackexchange.com/a/7220/162444

Good luck!

Community
  • 1
  • 1
J. Chomel
  • 8,193
  • 15
  • 41
  • 69
0

You can check the system with "unmane -a" and do a fine search, for example in AIX can use to get yesterday:

YESTERDAY=`TZ=aaa24 date +%Y%m%d`
Condemateguadua
  • 576
  • 5
  • 9