In Ubuntu and Fedora, when I type cal on the command line I get an ASCII calendar with the current day highlighted.

In OSX, when I type cal, I get an ASCII calendar but no day is highlighted.

How can I get the highlighting of the current date in OSX?

  • OSX and Linux use different implementations of cal. I imagine OSX's isn't written to highlight the current day. Commented Aug 24, 2015 at 21:36
  • @AndyDalton, I just noticed after your comment that OSX's version is 5 years older (2004 vs 2009) based on the man page.
    – merlin2011
    Commented Aug 24, 2015 at 21:43
  • 1
    @merlin2011 OS X uses “BSD cal” while Linux will be using “GNU cal”. Two different implementations rather than versions 😊
    – forquare
    Commented Aug 24, 2015 at 21:47

2 Answers 2


I've tried ubuntu, fedora, slackware, and netBSD and all the cal's automatically highlight the current day. However, I know some cals don't auto highlight, and either way, this does work:

cal | grep -C 6 --color -e " $(date +%e)" -e "^$(date +%e)"

Although I can't test on OS X as I do not have access to it.

  • 1
    This works for me in OS X 10.11 (El Capitan Public Beta 5). Today's date is highlighted in red.
    – forquare
    Commented Aug 24, 2015 at 21:45
  • 3
    or: cal | grep -E --color "(\b$(date +%d)\b|$)"
    – Peter.O
    Commented Aug 25, 2015 at 4:36
  • Just tried it on OS X (10.11.6). Works nicely. Commented Jul 31, 2019 at 14:30

The following prints the current date with a reversed field which is replaced in cal by sed.

ptd=$(date -j +%d)
ctd=$(printf "\033[0;7m"$ptd"\033[0m")
cal | sed 's/'"$ptd"'/'"$ctd"'/'
  • Replace the sequences of escape codes with (the output of) tput smso and tput rmso and you'll have something that works correctly when it's piped to a file, or even used on a different type of terminal. Commented Aug 24, 2015 at 22:28
  • Does not work for single digit dates. Example: today, date -j +%d prints 04 which does not appear in output of cal.
    – Wildcard
    Commented Oct 4, 2017 at 7:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .