SOLARIS 10日期算术 [英] SOLARIS 10 Date Arithmetic

查看:136
本文介绍了SOLARIS 10日期算术的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用X86 SOLARIS 10,需要以下bash脚本来获取昨天的日期。

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

得到错误GMT + 24:命令未找到。此外,尝试没有成功评论的方法。任何建议

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

推荐答案

您不能对Solaris自己的日期进行太多的日期算术命令。正如其他人指出,您将需要 GNU日期

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

请参阅这个链接,其中包含有关在Solaris上获取GNU date(GNU coreutils包的一部分)的信息。使其成为在Solaris服务器上始终部署最小GNU工具的规则(请参阅链接)。使其成为公司默认安装的一部分。那么你不会遇到这些问题。或者移动到最近的Solaris(*),默认情况下安装GNU日期。

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现在变得相当老了,现在我们在2014年12月。

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

这篇关于SOLARIS 10日期算术的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆