0% found this document useful (0 votes)
40 views

PR02

The document provides information about the cal and date commands in Linux/Unix. It includes: 1) The synopsis and description of the cal command, which displays a calendar and allows specifying the month and year. It provides options like -3 to show 3 months. 2) The synopsis and description of the date command, which prints or sets the system date and time. It allows specifying a custom format with options like +FORMAT. 3) Examples of using cal, date, banner and other commands, and exercises to use cal with different options like -3, -2000, specifying months/years. It shows output and errors for invalid options.

Uploaded by

Karunesh Kumbhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

PR02

The document provides information about the cal and date commands in Linux/Unix. It includes: 1) The synopsis and description of the cal command, which displays a calendar and allows specifying the month and year. It provides options like -3 to show 3 months. 2) The synopsis and description of the date command, which prints or sets the system date and time. It allows specifying a custom format with options like +FORMAT. 3) Examples of using cal, date, banner and other commands, and exercises to use cal with different options like -3, -2000, specifying months/years. It shows output and errors for invalid options.

Uploaded by

Karunesh Kumbhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Program Code

1. Write Down Different options of cal command $man cal


CAL(1) BSD General Commands Manual CAL(1)

NAME
cal, ncal — displays a calendar and
the date of Easter

SYNOPSIS
cal [-3hjy] [-A number] [-B number]
[[month] year]
cal [-3hj] [-A number] [-B number] -m
month [year]
ncal [-3bhjJpwySM] [-A number]
[-B number] [-W number]
[-s country_code] [[month] year]
ncal [-Jeo] [-A number] [-B number]
[year]
ncal [-CN] [-H yyyy-mm-dd]
[-d yyyy-mm]

DESCRIPTION
The cal utility displays a simple
calendar in traditional format and
ncal offers an alternative layout,
more options and the date of Easter.
The new format is a little cramped
but it makes a year fit on a 25x80
terminal. If arguments are not spec‐
ified, the current month is dis‐
played.
(1) line 1 (press h for help or q to quit)
2. Write options of date command. $man date
DATE(1) User Commands DATE(1)

NAME
date - print or set the system date
and time

SYNOPSIS
date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMD‐
Dhhmm[[CC]YY][.ss]]

1
DESCRIPTION
Display the current time in the
given FORMAT, or set the system
date.

Mandatory arguments to long options


are mandatory for short options
too.

-d, --date=STRING
display time described by
STRING, not 'now'

--debug
annotate the parsed date,
and warn about questionable
usage to stderr

(1) line 1 (press h for help or q to quit)

Assigned Commands
root@Karunesh:~# date
Sun Aug 20 17:33:18 IST 2023
root@Karunesh:~# cal
August 2023
Su Mo Tu We Th Fr Sa
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

root@Karunesh:~# banner OSY


####### ##### # #
# # # # # #
# # # # #
# # ##### #
# # # #
# # # # #
####### ##### #

root@Karunesh:~# tty
/dev/pts/0

2
root@Karunesh:~# script
Script started, output log file is 'typescript'.

Exercise
XIII. 1. a. $cal 04 2019
root@Karunesh:~# cal 04 2019
April 2019
Su Mo Tu We Th Fr Sa
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
XIII.1. b. $date “+Today’s information %D and %B”; cal
root@Karunesh:~# date "+Today's information %D and %B"; cal
Today's information 08/20/23 and August
August 2023
Su Mo Tu We Th Fr Sa
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
XIII.1. c. $date “+My Clock is Showing %H hours, %M minutes &
%S seconds”
root@Karunesh:~# date "+My Clock is Showing %H hours, %M minutes & %S seconds"
My Clock is Showing 17 hours, 22 minutes & 33 seconds
XIII.1. d. $cal -3
root@Karunesh:~# cal -3
2023
July August September
Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa
1 1 2 3 4 5 1 2
2 3 4 5 6 7 8 6 7 8 9 10 11 12 3 4 5 6 7 8 9
9 10 11 12 13 14 15 13 14 15 16 17 18 19 10 11 12 13 14 15 16
16 17 18 19 20 21 22 20 21 22 23 24 25 26 17 18 19 20 21 22 23
23 24 25 26 27 28 29 27 28 29 30 31 24 25 26 27 28 29 30
30 31
XIII.1. e. $cal -5

3
root@Karunesh:~# cal -5
cal: invalid option -- '5'
Usage: cal [general options] [-jy] [[month] year]
cal [general options] [-j] [-m month] [year]
ncal -C [general options] [-jy] [[month] year]
ncal -C [general options] [-j] [-m month] [year]
ncal [general options] [-bhJjpwySM] [-H yyyy-mm-dd] [-s country_code] [-W number of d
ncal [general options] [-Jeo] [year]
General options: [-31] [-A months] [-B months] [-d yyyy-mm]
XIII.1. f. $cal -2000
root@Karunesh:~# cal -2000
cal: invalid option -- '2'
Usage: cal [general options] [-jy] [[month] year]
cal [general options] [-j] [-m month] [year]
ncal -C [general options] [-jy] [[month] year]
ncal -C [general options] [-j] [-m month] [year]
ncal [general options] [-bhJjpwySM] [-H yyyy-mm-dd] [-s country_code] [-W number of d
ncal [general options] [-Jeo] [year]
General options: [-31] [-A months] [-B months] [-d yyyy-mm]

You might also like