发表于: 2007.09.12 09:39
分类: Solaris学习
出处: http://rainbowbridg.itpub.net/post/23663/394754
---------------------------------------------------------------
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











