0

Hellooo! I have the following sentence, that works on Linux, but not in Solaris Version.

YEAR=2019
echo $(expr '(' $(date -d $YEAR/9/30 +%s) - $(date +%s) + 86399 ')' / 86400) " days until deadline" the error is due to the date

Error that appears:

command date: illegal option -- d usage: date [-u] mmddHHMM[[cc]yy][.SS] date [-u] [+format] date -a [-]sss[.fff]

Any ideas?

Thank you very much

2 Answers2

1

The feature you are trying to use is included in GNU date (the default in Linux), but not in Solaris date.

You can install GNU date on Solaris from various third party repositories such as OpenCSW (free) or UNIXPackages ($).

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • 2
    Or it may be already installed as part of the OS under `/usr/sfw/bin` (Solaris 10) or `/usr/gnu/bin` (Solaris 11). – alanc Feb 16 '19 at 16:07
  • @alanc I'll go with that. Though it's been even longer since I used Solaris than it was for the other person. – Michael Hampton Feb 16 '19 at 17:25
0

It's been a little while since I've used Solaris. Last version I used was Solaris 10.
Answer: Solaris does not allow you to perform "date math." It does not like the -d option.

man date should show you that. There may be another option instead of -d, can't remember. Convert everything to seconds, maybe?

What, exactly, are you trying to accomplish?

Scottie H
  • 227
  • 2
  • 10