Using cal and ncal commands in Linux


A calendar is basically a chart in which days, weeks, months of a year are given in an organized way. By using the cal and ncal command in Linux you can see the calendar. The cal command displays the calendar in the traditional format while ncal offers an alternative layout and more options.

In this article, we will discuss the usage of cal and ncal commands in Linux with examples.

How to display calendar of the current month

By default when you use the cal command it shows the calendar of the current month. See the date and current month by executing the following command in your terminal –

cal

You can see the current date of the month is highlighted in the calendar.

How to display the calendar of a specific month

To display the calendar of a specific month lets say Feb 2020 use the following command in your terminal –

cal -m2

How to view the calendar of a specific year

Now let’s say you want to view the calendar for the year 2019 run the following command to view it –

cal -y 2019

Now see the output of this command –

How to view a specific month of a specific year

If you want to view a specific month of a specific year let’s say march of 2018. Then use the following command in your terminal –

cal -d 2018-03

How to display the Easter date

You can see the easter using the option -o with ncal command. Now use the following command to display the date of Easter in 2020.

ncal -o

How to display the Julian calendar

To view the Julian calendar which was proposed by Julius Ceasor in 46BC. You need to use the option -j with ncal command in your terminal.

ncal -j

To see more about cal or ncal command see its manual page. Execute the following command to view the man page –

man cal

Conclusion

You have seen the usage of cal and ncal commands in Linux. Now if you have a query then write us in the comments below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.