首页 > Linux操作系统 > Linux操作系统 > solaris里获取前一天的日期
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
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7916042/viewspace-969046/ ,如需转载,请注明出处,否则将追究法律责任。