I'm interested in outputting a representation of the current year-quarter, as well as the year-quarter for the previous month.
If today is 2012 January 1st, I'd like to get
2012q1
and
2011q4
as the respective outputs.
command linedate
I'm interested in outputting a representation of the current year-quarter, as well as the year-quarter for the previous month.
If today is 2012 January 1st, I'd like to get
2012q1
and
2011q4
as the respective outputs.
Best Answer
One (kinda ugly) solution, using BASH arithmetic evaluation and the GNU
date
command:Note that the
%-m
preventsdate
from 0-padding, so this will still work for August and September.