Shell Script Which Gets Executed With Greetings – The Moment User Logs In

Posted on in Categories Time and Date last updated April 5, 2008

Write shell script which gets executed the moment user logs in, it should greet user

Script first finds out current hour using date command

Depend upon time of the day, it will say Good morning or Good afternoon to user.

Open your bash / shell startup file i.e. profile file – ~/.bash_profile and put path to this script in file as follow:
/home/you/path/to/script

Sample shell script to greet user

Shell Script to read any year and find whether it is a leap year or not

Posted on in Categories Time and Date last updated April 5, 2008

A leap year comes once every four years. It is the year when an extra day is added to the Gregorian calendar used by most of the world.

An ordinary year has 365 days. A leap year has 366 days. The extra day is added to the month of February. In an ordinary year, February has 28 days. In a leap year, it has 29 days. This extra day is called a leap day.

How do I find out leap year?

A year is a leap year if it can be evenly divided by four. For example, 1996 was a leap year. But a year is not a leap year if can be evenly divided by 100 and not by 400. This is why 1700, 1800, 1900 were not leap years, but 2000 was.

Shell script to determine if entered year is leap or not…

Shell Script to find the validity of a given date

Posted on in Categories Time and Date last updated April 5, 2008

Date is entered in mm/dd/yyyy format using a keyboard. Various conditions are applied to make sure date is valid. Read the program comments to get idea about program logic.