Shell Script Calulate Area and Circumference of Circle

in Categories Shell Math last updated April 4, 2008

A circle is one of the simple shapes of Euclidean geometry. It is the locus of all points in a plane at a constant distance, called the radius, from a fixed point, called the center. Through any three points not on the same line, there passes one and only one circle.

A diameter is a chord passing through the center. The length of a diameter is twice the radius. A diameter is the largest chord in a circle.

Circles are simple closed curves which divide the plane into an interior and an exterior. The circumference of a circle is the perimeter of the circle, and the interior of the circle is called a disk.

Sample Shell Script To Calculate Area and Circumference of Circle

Shell script to read 3 numbers and find the greaters of the three

in Categories Shell Math last updated April 4, 2008

Shell Script to display current date, calendar, and the number of user logged

in Categories Academic last updated April 3, 2008

This script use the concept of command substitution. It allows allows the output of a command to replace the command name. There are two forms:

$(command)

or

command

Bash shell performs the expansion by executing command and replacing the command substitution with the standard output of the command, with any trailing newlines deleted. Embedded newlines are not deleted, but they may be removed during word splitting.

For example you can execute date command to display todays date and then set a variable called NOW:
NOW=$(date)
or
NOW=date
To display back variable value simply run echo command:
echo $NOW

Sample Shell Script

Shell Script to ask user his / her name and then display it with a G’Day/Good morning message

in Categories Academic last updated April 3, 2008

This script greets user with a message. Then it displays prompt asking user her name. Once name entered it will display Gooday message using echo command.

read statement will read one line from the user (keyboard) or from file and store it to a variable called yourname.

Shell script to find the number of files present in the current directory without using WC command

in Categories Academic last updated October 14, 2009