I want to print the calendar in terminal using cal -y command , but in reverse order. What should I add to print the calendar from December to January?


When you're satisfied with output in 1 column:

for m in {12..1}; do cal $m 2016; done

Really reversed, but probably not what you want:

cal -y | tac

Reversed in 3 columns by row of 3 months:

cal -y | perl -0777 -ne 's/\s*$//;@r=split /(\n(?=  +[A-Z]))/; print reverse @r';

And with the year still on top:

cal -y | perl -n0777e '
    s/\s*$//; @r=split /(\n(?= +[A-Z]))/; $y=shift @r;
    print $y,"\n",reverse @r;'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.