Unix Commands
The # prompt is known as the command prompt or also known as the shell prompt.
A UNIX command is a series of characters which are being typed. Those features consist of words which are separated through whitespaces. A Whitespace is the result of typing one or more Tab or Space keys. The first term is the name of the command. The rest of the words are known as the arguments of the command. The arguments provide the command information in which it may require, or specify varying behavior of the command. To invoke a command, the command name must be typed, followed through the arguments. The shell collects all the characters which are typed until the enter key is pressed and interprets them.
Date
The date command is commonly used for show the current date and current time of the system.
Syntax
date ["+<string> <options>"]
The given below options can be used in the date command
%D Displays the date with the format of MM/DD/YY
%d Displays the day of the month (01-31)
%m Displays the month (01-12)
%y Displays the year
The subsequent options can be used with the date command to show the weekdays and months in the abbreviated format:
%a Displays abbreviated weekdays (Sun-Sat)
%A Displays abbreviated weekdays (Sunday-Saturday)
%b Displays abbreviated months (Jan-Dec)
%B Displays abbreviated months (January-December)
The given below options can be used with the date command to show the current time.
%H Displays the hour
%M Displays the minutes
%S Displays the seconds
%I Displays the IST time
%r Displays the time with (AM/PM) meridian
%n Displays the output in the newline
Practice 1
The subsequent example shows how to display the current date and time.
# date
Sat May 15 14:09:01 GMT 1999
As seen above, the date command provides the day of the week, month, day, time (24 hour clock, Greenwich Meantime) and the year.
Practice 2
The given example shows how to display the date with strings.
# date "+ Current Date : %D"
Current Date : 09/22/00
In the above given example the date is displayed with the string "Current Date".