0% found this document useful (0 votes)
5 views

SHELL SCRIPT_

The document contains multiple shell scripts that perform various tasks such as calculating the area and circumference of a circle, solving quadratic equations, counting vowels in a word, determining if a year is a leap year, finding the greatest of three numbers, calculating the sum and percentage of marks in five subjects, and providing system information based on user input. Each script prompts the user for input and outputs the result accordingly. The scripts demonstrate basic shell scripting techniques and conditional statements.

Uploaded by

tamilmozhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

SHELL SCRIPT_

The document contains multiple shell scripts that perform various tasks such as calculating the area and circumference of a circle, solving quadratic equations, counting vowels in a word, determining if a year is a leap year, finding the greatest of three numbers, calculating the sum and percentage of marks in five subjects, and providing system information based on user input. Each script prompts the user for input and outputs the result accordingly. The scripts demonstrate basic shell scripting techniques and conditional statements.

Uploaded by

tamilmozhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

SHELL SCRIPT:

#!bin/bash
echo “enter the number:”
read radius
pi=3.14
area=$(echo “$pi*$radius*$radius”|bc)
circumference=$(echo “2*$pi*$radius”|bc)
echo “$area”
echo “$circumference”

OUTPUT:
SHELL SCRIPT:

#!bin/bash
echo “enter a:”
read a
echo “enter b:”
read b
echo “enter c:”
read c
n=$(echo “$b*$b-4*$a*$c”|bc -l)
r1=$(echo “(-$b+sqrt($n))/(2*$a)”|bc -l)
r2=$(echo “(-$b-sqrt($n))/(2*$a)”|bc -l)
echo “$r1”
echo “$r2”

OUTPUT:
SHELL SCRIPT:

#!bin/bash
echo “enter the word:”
read word
echo “$word” | tr -cd ‘aeiouAEIOU’ | wc -c
echo “vowels”

OUTPUT:
SHELL SCRIPT:

#!bin/bash
echo "Enter the year"
read y
b=`expr $y % 4`
if [ $b -eq 0 ]
then
echo "$y is a leap year"
else
echo "$y is not a leap year"
fi

OUTPUT:
SHELL SCRIPT:

#!/bin/bash
echo "enter three numbers:"
read num1
read num2
read num3
if [ $num1 -ge $num2 ] && [ $num1 -ge $num3 ]; then
max=$num1
elif [ $num2 -ge $num1 ] && [ $num2 -ge $num3 ]; then
max=$num2
else
max=$num3
fi
echo "the greatest number is: $max"

OUTPUT:
SHELL SCRIPT:

#!/bin/bash
echo "Enter marks for 5 subjects:"
read m1 m2 m3 m4 m5
sum=$((m1 + m2 + m3 + m4 + m5))
percentage=$((sum / 5))
echo "sum of 5 subjects is: $sum"
echo "the percentage is: $percentage"
if [ $percentage -ge 75 ]
then
echo "you got distinction"
elif [ $percentage -ge 60
then
echo "you got first class"
elif [ $percentage -ge 50 ]
then
echo "you got second class"
elif [ $percentage -ge 35 ]
then
echo "you passed"
else
echo "you failed"
fi

OUTPUT:
SHELL SCRIPT:

#!/bin/bash
echo "Type one of the following options:"
echo "1. who am i"
echo "2. who is logged on"
echo "3. date"
echo "4. calendar"
read choice
case $choice in
1) whoami ;;
2) who ;;
3) date ;;
4) cal ;;
*) echo "Invalid option" ;;
esac

OUTPUT:

You might also like