cal - Unix, Linux Command


Advertisements

Previous Page
Next Page  
 

NAME

cal- displays a calendar

SYNOPSIS

cal [-3hjy] [-A number] [-B number] [[month] year]
cal [-3hj] [-A number] [-B number] –m month [year]

DESCRIPTION

Cal displays a simple calendar. If arguments are not specified, the current month is displayed.

OPTIONS

TAG DESCRIPTION
-1 Display single month output. (This is the default.)
-3 Display prev/current/next month output.
-s Display Sunday as the first day of the week.
-m Display Monday as the first day of the week.
-j Display Julian dates (days one-based, numbered from January 1).
-y Display a calendar for the current year.
-V Display version information and exit.

EXAMPLES

EXAMPLE-1:

How to show a calendar in the terminal

 To show a calendar in the terminal simply run the cal command. 
 This will output a calendar of the current month with the current day highlighted.
$ cal

output: September 2016 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

EXAMPLE-2:

 To get  output of  more than one month

To get output of  more than one month pass the -n option along with the number of 
months that you wish to show.
	
$ cal -n 2

output: September 2016 October 2016 Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su 1 2 3 4 1 2 5 6 7 8 9 10 11 3 4 5 6 7 8 9 12 13 14 15 16 17 18 10 11 12 13 14 15 16 19 20 21 22 23 24 25 17 18 19 20 21 22 23 26 27 28 29 30 24 25 26 27 28 29 30 31

EXAMPLE-3:

To display week numbers

To display week numbers pass the -w option. This modifies the output to display 
 the week number before each row.

$ cal -w

output: September 2016 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

EXAMPLE-4:

To display the day of the year in numbers

To display the day of the year in numbers (or Julian dates) pass the -j option. This displays days numbered from January 1.
	
$ cal -j

output:
September 2016 Mon Tue Wed Thu Fri Sat Sun 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274

EXAMPLE-5:

To print a calendar for a particular day, month and year

To print a calendar for a particular month and year pass the day month and year to the cal command.
	 
$ cal 25 01 1977

output: January 1977 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

EXAMPLE-6:

 To print a calendar of three  months  for a particular day, month and year,

This can also be combined with other options.

	
$ cal -3 25 01 1977
    
	December 1976         January 1977          February 1977
Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su
       1  2  3  4  5                  1  2      1  2  3  4  5  6
 6  7  8  9 10 11 12   3  4  5  6  7  8  9   7  8  9 10 11 12 13
13 14 15 16 17 18 19  10 11 12 13 14 15 16  14 15 16 17 18 19 20
20 21 22 23 24 25 26  17 18 19 20 21 22 23  21 22 23 24 25 26 27
27 28 29 30 31        24 25 26 27 28 29 30  28
                      31

Previous Page
Next Page