Reputation: 61
I know the command many display current month and year .
#date +%b%Y
Jun2015
If I want to show the last month and year ( as current month is Jun2015, I would like display May2015 , if current is Jan2016 , then display Dec2015 ) , would advise what can I do ? thanks
Upvotes: 0
Views: 61
Reputation: 31284
you can specify a relative date you want to be printed:
$ date --date 'last month' +'%b%Y'
May2015
Upvotes: 1
Reputation: 2953
date --date='-1 month' +'%b%Y'
example:
date --date='-7 month' +'%b%Y'
Gives: "Nov2014"
Upvotes: 1