Posts tagged as:

elif

#!/bin/bash
# Shell script to restart MySQL server if it is killed or not working
# due to ANY causes.
# When script detects mysql is not running (it basically sends ping request
# to MySQL) it try to start using /etc/init.d/mysql script; and it sends an
# email to user indicating the status.
# This script must be run from [...]

{ 4 comments }

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 [...]

{ 1 comment }

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 [...]

{ 0 comments }

This script uses sed command to find out all digits or upper characters. -z string (conditional expression) will return true if the length of string is zero.
Script logic
Read one character
[1] Use sed command to determine input character is digit or not (sed -e ’s/[A-Z]//g’))
[2] Attempt to match regex [0-9] i.e. all digit against [...]

{ 2 comments }

#!/bin/bash
# Shell script to read 3 numbers and find the greaters of the three
# ————————————————————————-
# Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# ————————————————————————-
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# ———————————————————————-
echo -n "Please enter three numbers (separate [...]

{ 2 comments }