cal
Display a text calendar in the terminal
By CMD Script Team · 4 min read · Last updated
cal [OPTIONS] [[MONTH] YEAR]Options
| Flag | Description |
|---|---|
-3 | Show the previous, current, and next month side by side |
-y | Show a full 12-month calendar for the current year |
-m | Start the week on Monday instead of the locale default (util-linux cal) |
-j | Display Julian day numbers (day of the year, 001-366) instead of day of month |
-1 | Show only a single month (the default behavior when no options are given) |
Distribution compatibility
- Ubuntu
- Debian
- Fedora
- Arch
- macOS (BSD cal, supports -3/-y/-j; -m for Monday-start not standard)
What it does
cal prints a simple text calendar to the terminal. With no arguments it shows the
current month, highlighting today's date. Given a year, it prints all twelve months of
that year; given both a month and year, it prints just that specific month — a fast way
to check dates without opening a graphical calendar app.
Beginner examples
cal— show the current month, with today highlightedcal 2026— show every month of the year 2026cal 7 2026— show July 2026 specificallycal -3— show last month, this month, and next month together
cal -3
Advanced examples
- Print the entire current year at a glance:
cal -y - Check what day of the week a specific future date falls on:
cal 12 2026and scan for the date - Show Julian day-of-year numbers instead of calendar days:
cal -j - Quickly verify month boundaries when scripting date-based logic by cross-checking
against
cal -3 - Combine with
dateto confirm "today" lines up with whatcalhighlights:date +%F; cal
cal -y
Common mistakes
- Typing
cal 2026expecting July 2026 and getting the entire year instead — a single numeric argument is interpreted as a year, not a month; you needcal 7 2026for a specific month. - Confusing week-start conventions between locales/systems — some configurations start the week on Sunday, others on Monday, which can make date columns look "off" if you're not expecting it.
- Assuming
cal's single-argument year behavior is universal across allcalimplementations without testing — BSD and util-linux versions can differ slightly in argument parsing and defaults.
Tips
- Use
cal -3when working out date math near a month boundary (e.g. "is the 30th a Friday, and what's the first Monday of next month?"). cal -yis a handy quick reference for annual planning without opening a full calendar application.- Pipe
cal's output intogrep(with color) to visually spot a specific day number quickly in a big block of text, though highlighting today only works in the live terminal, not through a pipe.
Best practices
- Prefer
cal -3orcal -yover repeatedly re-running plaincalwith different month/year arguments when comparing nearby dates — it reduces context-switching. - When scripting date logic, don't parse
cal's visual output — usedatewith format strings instead;calis meant for human viewing, not machine parsing. - Be explicit with both month and year (
cal 7 2026) rather than relying on defaults when precision matters, since a barecal <number>is always interpreted as a year.
Try it yourself
A simulated shell with a sample home directory — experiment freely, nothing leaves your browser. Type help to list supported commands.
Real-world use cases
- Quickly checking what day of the week a specific date falls on when scheduling a meeting or deployment.
- Glancing at the upcoming month's layout to plan a release calendar directly from the terminal.
- Verifying date-related assumptions while writing or debugging scripts that compute "next Monday" or "last day of the month".
Common interview questions
- How do you display a specific month and year with
cal?cal <month> <year>, e.g.cal 7 2026for July 2026 — a single numeric argument alone is interpreted as a full year. - How would you view three consecutive months at once?
cal -3, which shows the previous, current, and next month side by side. - Is
calsuitable for use in scripts that need to compute dates? Not really — it's designed for human-readable display;datewith format strings and arithmetic (-d) is the right tool for programmatic date calculations.
Frequently Asked Questions
How do I see a calendar for a specific year, like 2026?
Run cal 2026, which prints all 12 months of that year. To see one specific month and year, use cal MONTH YEAR, e.g. cal 7 2026 for July 2026.
How do I see last month, this month, and next month together?
Use cal -3, which lays out three consecutive months side by side with the current month in the middle, making it easy to see dates spanning a month boundary.
Does cal know about historical calendar changes?
Yes — running cal 9 1752 on systems that replicate the classic Unix behavior shows the historical September 1752 calendar with 11 days missing, from the switch to the Gregorian calendar in Britain and its colonies. Modern util-linux cal may or may not reproduce this depending on version/locale.
Cheat sheet
Download a quick-reference cheat sheet for cal.