Hi All,
I wanted to add 1 year to the system date in my script.
say export start_date=`date +%F`
echo $start_date
o/p of this is 2009-09-02
To this i want to add 1 year.
the output i need here is 2010-09-02
can anybody help me ?
Thanks in advance,
Vinay
One "stupid" way to do that :
export start_date=$(echo $(echo `date +%Y` + 1 | bc)-$(date +%m)-$(date +%d))
There must be a smarter solution ^^
danmero
3
man date like always
On FreeBSD I use
# date -v +1y +%F
2010-09-02
Tytalus
4
well...since years don't have awkward diferent lengths like months you could do:
date +%F | awk '{FS=OFS="-";$1++;print}'
2010-09-02
danmero
5
My awk don't like Tytalus solution
date +%F | awk 'BEGIN{FS=OFS="-"}{$1++}1'
2010-09-02