On Fri, Apr 18, 2014 at 04:06:18PM +0200, Ingo Schwarze wrote:
> Hi,
> 
> lilit-aibolit wrote on Fri, Apr 18, 2014 at 03:24:36PM +0300:
> 
> > $ date --date="last month" +%b
> > Mar
> 
> Time for a little shell golfing?
> 
> Look, i'll play it nice and even add two blanks for readability.
> 
> $ date -j +%b $(printf "%02d010000" $(( ($(date +%m)+11)%12 )))
> Mar

You don't like January?

$  date -j +%b $(printf "%02d010000" $(( (01+11)%12 )))
date: illegal time format
usage: date [-aju] [-d dst] [-r seconds] [-t minutes_west] [-z output_zone]
            [+format] [[[[[[cc]yy]mm]dd]HH]MM[.SS]]

My handicap doesn't allow do include a better version. ;)

Reply via email to