2014-11-18

Shell Script to get last month date


Source URL: http://www.unix.com/unix-for-dummies-questions-and-answers/99281-how-get-previous-month-using-date.html




















j=`date +"%m"`; echo $j; i=`expr $j - 1`; echo $i;


Output:
11
10





enhance:

j=`date +"%m"`; echo $j; i=`expr $j - 1`; echo $i; echo `date +"%Y$i%d_%p%H%M"`

Output:
11
10
20141018_AM0340





No comments:

Post a Comment