1
I am trying to execute date command in unix server for yesterday. The commands tried are :
date --date="1 day ago"
date --date="1 days ago"
date --date="yesterday"
date --date="-1 day"
These command work in a server but the same command does not work in few other servers, where date prints properly the current date. Could anyone suggest what could be the issue with the other servers?
I get an error like : illegal option -- date=1 day ago
The server Details: SunOS wupsa02a0014 5.10 Generic_147440-15 sun4u sparc SUNW,SPARC-Enterprise
1Two suggestions: (1) ask on a site where the question isn't off-topic; (2) include
uname -a
for the servers where this isn't working. – NPE – 2013-03-27T07:12:06.133That's because
--date="1 day ago"
isn't portable. – None – 2013-03-27T07:12:22.680@NPE Thanks for suggestion. Could you please give an example how can I add the uname -a ? – None – 2013-03-27T07:13:38.757
1He isn't asking you to use uname -a to solve your problem, he wants to know which version(s) you are running on the machines giving you the issue. – Randy Howard – 2013-03-27T07:14:29.527
SunOS wupsa02a0014 5.10 Generic_147440-15 sun4u sparc SUNW,SPARC-Enterprise – None – 2013-03-27T07:15:50.523
You (or someone who uses
date --date
) suffers from the all the world's a GNU/Linux system. Learn what are POSIX options and what are GNUisms, Linuxisms, bashisms. Then you can write portable scripts working on Solaris as well as Linux and many other OSs. Often the manual page tells you which options are standard and which are not. – Jens – 2013-03-27T09:03:43.260