UNIX Command to display

UNIX Command to display

UNIX Command to display:In this blog post we will see some UNIX display commands with example. Some important commands are Cal [ [ month ] year ], date [ +format ] and Echo[-n]text.

UNIX Command to display Calendar

Cal print a calendar
Synax:
Cal [ [ month ] year ]
Where year is a number between 1 and 9999 and month is a number between 1 and 12:
Example 1: No arguments are specified
The current, previous, and following months are printed, along with the current date and time.
$ cal
Example2:
Only month is specified
$cal jan
Example 3:
Calendar for the year 2005 is displayed
$ cal 2005

UNIX Command to display system date and time

Date to see date and time S
Syntax: date [ +format ]
The format specifier is proceeded by a +followed by a%. Some of the format specifiers are as follows:
Format
What is specifies
+%m
Specifies the month number (1 to 12)
+%h
Specifies the abbreviated month(jan-dec)
+%B
Specifies the full month name
+%d
Specifies the day of the month (1 to 31)
+%y
Specifies the year (2 digits)
+%H, +%M and +%S
Specifies the hour, minute and seconds
+%D
Specifies the date as mm/dd/yy
+%T
Specifies the time as hh:mm:ss
Example 1: without arguments, date displays the current date and time.
$ date
Thu Dec 16 13:25:00 IST 2004
Example 2:
$ date +%D
12/27/04
Example 3:
$date + ‘%d%h%y’
27 Dec 04

UNIX Command to display message: echo

Echo: writes it arguments separated by blanks and terminated by a new line on the slandered output
Syntax:
Echo[-n]text
The n option points a line without a new line.
Example:
$ echo Hello
Hello
An alternative to echo: printf
Write formatted output
Syntax:
Printf format [argument]

Leave a Reply

Your email address will not be published.