SOLARIS 10 Date Arithmetic

余生长醉 提交于 2019-12-11 13:26:10

问题


I am using X86 SOLARIS 10 and need the following bash script to get yesterday's date.

   #!/usr/local/bin/bash
   #ds=`date '+%Y%m%d' -d "+2 days"`
       ds=`GMT+24 date +%Y%m%d`
   #ds=`date --date yesterday +%Y%m%d`
   echo $ds

Getting an error "GMT+24: command not found". Also, tried the methods that are commented without success. Any suggestion


回答1:


You can't do much date arithmetic with Solaris's own date command. As others have pointed out you'll need GNU date.

See this link, which includes information on getting GNU date (part of GNU coreutils package) on Solaris. Make it a rule to always deploy the minimal GNU tools on your Solaris servers (see link). Make it part of your company's default install. Then you won't get into these issues. Or move to more recent Solaris(*) where GNU date is installed by default.

*) Solaris 10 is getting fairly old now that we're in Dec 2014.



来源:https://stackoverflow.com/questions/27258707/solaris-10-date-arithmetic

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!