ITPub博客

首页 > Linux操作系统 > Linux操作系统 > solaris里获取前一天的日期

solaris里获取前一天的日期

原创 Linux操作系统 作者:rainbowbridg 时间:2007-09-12 09:39:05 0 删除 编辑

1. If you are using GNU date, just do :
filename = 'date +%m' +100

2. For POSIX date, it's a bit complex, you should try:
2.1 Write a simple C programm to archive this, just one function call can solve this.

2.2 Write a perl script file to caculate the assigned date.
#!/usr/local/bin/perl -w

@t=localtime(time-N*24*3600);
# N states for how many days you want to count behind.

print("%04s%02s%02s%02s",$t[5]+1900,$t[4]+1,$t[3],$t[2]);
#END

2.3 It's rather complex to realize this by sole shell script, I just serach one paragraph on ChinaUnix, perhaps it's fit...
http://chinaunix.net/jh/24/15824.html

If only for a day ago, this might works:
Yesterday=`TZ=${TZ}+24 date +%D`
echo $Yesterday

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7916042/viewspace-969046/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    237
  • 访问量
    1586342