Friday, 26 May 2023

Write a shell script to perform addition, subtraction, multiplication and division operations on two given numbers.

 CODE


echo "Enter Two Integer Numbers ::"

read n1 n2

sum=`expr $n1 + $n2`

sub=`expr $n1 - $n2`

mul=`expr $n1 \* $n2`

div=`expr $n1 / $n2`

echo "Addition :" $sum

echo "Subtraction :" $sub

echo "Multiplication :" $mul

echo "Division ::" $div

Write a Shellscript to find sum of three given numbers

CODE


 n1=10

n2=20

n3=15

sum=`expr $n1 + $n2 + $n3`

echo " SUM = " $sum

Write a Shell script to find sum of two given numbers

CODE 


n1=10

n2=20

sum=`expr $n1 + $n2`

echo " SUM = " $sum

Write a shell script to display system date in following format:

 Output :

 Today is September 24 2009

 Today is Thursday

 Time is in hh: mm: ss AM/PM


Code :


NOW=$(date +"%B %C %Y")

 echo "Today is" $NOW

 NNOW=$(date +"%A")

 echo "Today is" $NNOW

 TTIME=$(date +"%r")

 echo "Time is " $TTIME

Output :

$ sy1.sh

Today is March 01 2021

Today is Monday

Time is 10:44:12 AM