cal - Linux Command
cal command displays the calendar of the current month or a month specified as the option with the command. Consider cal as the abbreviation of "calendar".When you use the command cal, you get the calendar of the current month and the current date is automatically highlighted. If you specify a month and a year, it will show the calendar for this specific month. If you specify just a year, it will show the calendar for this whole year.
What does the "cal" command do?
The cal command displays a calendar in your Linux terminal. If no option or parameter is provided and simply the "cal" command is used, it displays the current calendar month and highlights the current date.However, the "cal" command can display multiple months, the calendar of a whole year including the future years and so on. It also supports starting the week on a Saturday, Sunday or Monday and can display Julian dates. So let's explore this command and display/find dates right from your Linux terminal.
Syntax:
Note: Rectangular bracket "[ ]" means it is optional.$
cal [ month ] [year]
"cal" use and options:
cal : displays the calendar of the current month and the current date is highlighted.cal 06 2018 : displays the calendar of the 6th month of the year 2018. In that case, no date will be highlighted.
cal Nov 2014 : displays the calendar of November month of the year 2014.
cal November 2016 : displays the calendar of November 2016.
cal May 2025 : displays the calendar of May 2025.
cal 2018 : displays the calendar for the whole year of 2018.
cal -3 : display calendar of previous, current and next month. Interestingly, you can't use other numbers than 1 and 3. "1" here means the current month. Thus using cal -6 would not display any result.
cal -3 July 2017 : To display any three consecutive months of any year, us this command. In this particular example, it will show the calendar of June, July and August 2017.
How to use the cal command:
1. Display the current month's calendar and highlight today's date: cal. [you can also sue "ncal" command]
2. Display the calendar of the entire year: cal 2018.
['2018' is a year here. You can specify any year you need including future years. So If you want to see the calendar of the year 2050, just use the command cal 2050.]
3. Display the calendar of March 2015 : cal March 2015 or cal Mar 2015 or cal 03 2015 or cal 3 2015.
['2015' is a year here. You can specify any month and any year you want.]
4. Display the calendar of the last 3 months (previous, current and next months) : cal -3.To display any three consecutive months of any year, use the command cal -3 and then give the month and year. For example, to show the calendar of January, February and March 2012, use the command cal -3 July 2012.
5. Display the day of the year in numbers (like the Julian dates) for the current month: cal -j.
To display the day of the year in numbers (like the Julian dates) for the entire year: cal -j 2016.['2016' is a year here. You can specify any year you want.]
More in-depth resources on "cal":
1. GeekforGeek cal command page:
2. Wikipedia page for "cal" Linux command:
3. Linux and Unix cal command tutorial with examples:
4. HowtoForge page for Unix/Linux cal command:
5. Calendar (cal) on Linux command line:
Comments
Post a Comment