cal command in Linux offers quick view of calendar within Linux terminal interface. Means, if a user want to view calendar from command line, this command can be helpful. This command shows the current month calendar as output by default, however the output can be altered according to requirement by using various options.
Table of Contents
Syntax of cal command in Linux
cal or cal [ [ month ] year]
Options available to use with cal command:
- -h: Used for not highlighting today’s date.
- -m month: Used for specifying month (Either use full month name, or the first three letters. Month number can also be specified)
- -y year: Specifies a year to display.
- -3: Shows 3 consecutive month calendar starting from last month.
- -1: Shows current month only.
- -A num: Shows num (number) months after a specified month.
- -B num: Displays num (number) months before specified month.
- -d YYYY-MM: Shows the specified month of specified year (Eg. 1998-05)
- -j: Used for showing Julian calendar (Default calendar type is Gregorian).
Examples of cal command in Linux
1: Displaying calendar of current month
2: Display 3 consecutive month from last month, with highlighting todays date.
3: Display complete year’s calendar
cal -y 1997
4: Display a specified month of this year
cal -m Feb or cal -m2
Nishant Verma is a senior web developer who love to share his knowledge about Linux, SysAdmin, and more other web handlers. Currently, he loves to write as content contributor for ServoNode.