得到一个previous日期在bash / UNIX [英] getting a previous date in bash/unix
问题描述
我希望得到previous日期UNIX / shell脚本。
我用下面的code
日期-d'1天前'+'%Y /%M /%D'
不过,我收到以下错误。
日期:非法选项 - ð
据我读过的inetrnet,这基本上意味着我使用GNU的旧版本。任何人都可以请帮助这一点。
进一步信息
UNIX> -a的uname
的SunOS 5.10服务器Generic_147440-19 SUN4V SPARC SUNW,太阳火-T200
还有下面的命令给出错误。
UNIX>日期--version
日期:非法选项 - 版本
用法:日[-u] MMDDHHMM [[CC] YY] [。SS]
日期[-u] [+格式]
日期-a [ - ] SSS [.fff]
几种解决方案建议在此假设 GNU的coreutils
是$ P $系统上psent。以下应在Solaris上运行:
TZ = GMT + 24日期+%Y /%M /%D'
I am looking to get previous date in unix / shell script .
I am using the following code
date -d ’1 day ago’ +’%Y/%m/%d’
But I am getting the following error.
date: illegal option -- d
As far as I've read on the inetrnet , it basically means I am using a older version of GNU. Can anyone please help with this.
Further Info
unix> uname -a
SunOS Server 5.10 Generic_147440-19 sun4v sparc SUNW,Sun-Fire-T200
Also The below command gives an error.
unix> date --version
date: illegal option -- version
usage: date [-u] mmddHHMM[[cc]yy][.SS]
date [-u] [+format]
date -a [-]sss[.fff]
Several solutions suggested here assume GNU coreutils
being present on the system. The following should work on Solaris:
TZ=GMT+24 date +’%Y/%m/%d’
这篇关于得到一个previous日期在bash / UNIX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!