Updated April 19, 2023
Introduction of Linux Cal Command
In the Linux ecosystem, the cal is standing for the calendar. The cal is a command-line utility to display the calendar information on the Linux terminal window. It will help to print the single month calendar, multiple or many month calendars and the entire year as well. If we will just simply enter the “cal” command without any option then it will print the current month of the calendar. The cal command is part of the util-linux package.
Note: In cal command, there is functionality to print the year from 1 to 9999. But we need to specify the full year with the cal command. (Ex. if we need to print the calendar information of the year 1999. Then we cannot use the “99” we need to fully specify the year “1999”.
Syntax:
cal [options] [[[day] month] year]
- cal: We can use the cal keyword in the syntax or command. It will take the two arguments as an option and the date parameter.As per the provided arguments, it will provide the month or year information in the calendar format.
- option: We can provide the different flags as options that are compatible with the cal command.
- date, month, year: As per the requirement, we can use the different parameters of date, month, and year with the “cal” command.
How does Linux Cal Command work?
Basically, the cal is command-line utility to print the month or year calendar information on the Linux terminal window. The cal command will accept the different compatible option with the date and year parameters. According to the argument, the “cal” command will print the request calendar information.
Below are the lists of options available in the cal command.
Option | Description |
-1, –one | It will simply display the current month of information. |
-3, –three | It will print the month information of previous, current and next month |
-s, –sunday | It will start the month by considering the Sunday as the starting week |
-m, –monday | It will start the month by considering the Monday as the starting week |
j, –julian | By default, the cal will display the Gregorian calendar. But with the help of the “-j” option, it will display the Julian calendar. All days are numbered from the beginning of the month. |
-y, –year | It will print the complete current whole year |
-V, –version | It will print the version information of the cal command. |
-h, –help | It will display this help option those are compatible with cal command. |
Examples to Implement Linux Cal Command
Following are examples are given below:
CalCommand
It is very simple and common cal command in a Linux environment. It will print the current month information in the Linux terminal.
Command:
cal
Explanation: As per the above command, the cal command is printing the current month of the calendar. The current month is July 2020. It is also highlighting the current date as well i.e. 25th July.
Output:
Cal Command – Print Specific Month Calendar
By default, we are able to print the current month calendar with highlight date. If we want to print the specific month and the year then we can print on the Linux terminal.
Command:
cal 01 2010
Explanation: As per our requirement, we are able to print the specific month and year calendar. As per the below screenshot, we are printing the calendar of January month of the 2010 year.
Output:
Cal Command – With “-m” Option
In cal command, we are able to print the month calendar with the starting week of Monday. We need to use the “-m” option with the cal command.
Command:
cal -m
Explanation: Generally, in cal command, the starting week of the month is Sunday. But as per our requirement, we can change it from Sunday to Monday. As per the below screenshot, we have changed the starting week from Monday.
Output:
CalCommand – With “-s” Option
In cal command, we are able to print the month calendar with the starting week of Sunday. We need to use the “-s” option with the cal command.
Command:
cal -s
Explanation: As per our requirement, we can display the starting week from Sunday in the call command. As per the below screenshot, the starting week of the July month is Sunday.
Output:
CalCommand –Print the previous, current and next month calendar
In cal command, we are having the functionality to print the previous, current and next month calendarin a single command.
Command:
cal -3
Explanation: As per the above command, we are able to print the three-month calendar information. The current month is July; we can print the calendar information of previous as well as the next month of July i.e. June and August.
Output:
Cal command – With “-j” Option
In cal command, we are able to print the Julian calendar on the Linux terminal. We need to use the “-j” option with the cal command.
Command:
cal -j
Explanation: As per the above command, we are able to print the Julian calendar. In the Julian calendar, all days are numbered from the beginning of the month.
Output:
Cal Command – Print Year Calendar
In the cal command, we are having the functionality to print the complete one year calendar. We can print the calendar from 1year to 9999 years.
Note: While print the one year calendar, we need to specify the complete or full year in the cal command.
Command:
cal1800
Explanation: As per the below screenshot, we are able to print the complete month calendar of the 1800 year.
Output:
Conclusion
We have seen the uncut concept of “Linux cal command” with the proper example, explanation, and command with different outputs. The cal command is very important to print all the month of the specific year. We can use the cal command with multiple options like a month, Julien calendar, change the working day, etc.
Recommended Articles
We hope that this EDUCBA information on “Linux Cal Command” was beneficial to you. You can view EDUCBA’s recommended articles for more information.