cal -3

Displays a 3-Month Calendar

the -3 show the previous, current, and next month.
Sample Output
$ cal -3
     March 2009            April 2009             May 2009       
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa 
 1  2  3  4  5  6  7            1  2  3  4                  1  2 
 8  9 10 11 12 13 14   5  6  7  8  9 10 11   3  4  5  6  7  8  9 
15 16 17 18 19 20 21  12 13 14 15 16 17 18  10 11 12 13 14 15 16 
22 23 24 25 26 27 28  19 20 21 22 23 24 25  17 18 19 20 21 22 23 
29 30 31              26 27 28 29 30        24 25 26 27 28 29 30 
                                            31

-3
By: haivu
2009-04-02 17:40:38

These Might Interest You

  • Displays a calendar. Show Sample Output


    0
    cal [[month] year]
    raphink · 2009-02-16 15:33:46 0
  • Explanation: * The date command evaluated to today's date with blank padded on the left if single digit * The grep command search and highlight today's date * The --before-context and --after-context flags displays up to 6 lines before and after the line containing today's date; thus completes the calendar. I have tested this command on Mac OS X Leopard and Xubuntu 8.10


    4
    cal | grep --before-context 6 --after-context 6 --color -e " $(date +%e)" -e "^$(date +%e)"
    haivu · 2009-03-04 06:46:52 4
  • Using the gcalcli interface to google calendar, print the calendar for the next 2 weeks according to the width of the terminal being used. * Remove "--mon" to start week on sunday, * Change 2 for more or less weeks gcalcli --mon --width $((COLUMNS/8)) calm for whole month Show Sample Output


    0
    gcalcli --mon --width $((COLUMNS/8)) calw 2
    jaw42 · 2013-07-04 12:28:51 0
  • This produces a parseable output of the last day of the month in future or past. Change the '-v-0m' to be a month plus or minus from the current system time. Show Sample Output


    -4
    date -j -v1d -v-0m -v-1d +'%m %d %Y'
    drewk · 2010-03-04 17:47:51 1
  • Contrary to logic, typing calendar won't show a calendar, that's the job of cal. Typing calendar will show some trivia related to the current date. Tested against many Linux distros and FreeBSD. Show Sample Output


    6
    calendar
    vlan7 · 2010-01-29 11:17:11 3
  • Choosing your year and month. You only need the gnu date command and bash. desiredDay of the week is (1..7); 1 is Monday. If you want desiredDay of week (0..6); 0 is Sunday desiredDay=6; year=2012; month=5; n=0; while [ $(date -d "$year-$((month+1))-1 - $n day" "+%w") -ne $desiredDay ]; do n=$((n+1)); done; date -d "$year-$((month+1))-1 - $n day" "+%x" Show Sample Output


    0
    desiredDay=6; year=2012; month=5; n=0; while [ $(date -d "$year-$((month+1))-1 - $n day" "+%u") -ne $desiredDay ]; do n=$((n+1)); done; date -d "$year-$((month+1))-1 - $n day" "+%x"
    ClashTheBunny · 2012-05-17 12:02:30 0

What Others Think

Does not appear to be available in the OS X implementation. "man cal" doesn't mention it, and using it gets an illegal option error.
cczona · 477 weeks ago
@cczona: You are correct. I forgot to test it against OS X.
haivu · 476 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: