Assignment#3
Assignment#3
P3: Program to a simple script to read user input and perform operations with them.
read NUM1 # Read the user input from Standard Input and store in Variable NUM1
read NUM2
NUM2=2
then
echo "NUM1 > NUM2"
fi
NUM2=5
then
else
fi
read NUM
if [ $NUM -gt 0 ]
then
then
else
fi
echo "done"
P7: A script to demonstrate case statement.
read CHAR
case $CHAR in
*) echo "You entered $CHAR which is not a vowel";; # Defaults to everything else
esac
echo "What if you enter upper case letters!!?, Check the next example"
read CHAR
case $CHAR in
# You may write commands in this fashion too!!, means multiline commands
e | E)
;;
i | I)
echo "You entered $CHAR which is a vowel"
;;
o | O)
;;
u | U)
;;
;;
esac
read USER_INPUT
case $USER_INPUT in
;;
;;
Esac
P10: A simple script to show usage of string compare operator = and !=.
STR1="Hello"
STR2="Hello"
if [ ${STR1} = ${STR2} ]
then
else
fi
P11: A simple script to show usage of string compare operator -z and -n.
STR1="Hello"
STR2="Hello"
if [ -z "${STR1}" ]
then
else
fi
echo ":$STR:"
if [ -n "${STR2}" ]
then
else
fi
P12: A simple script to show usage of logical operators.
read NUM
then
else
fi
read NUM
then
else
fi
COUNT=0
do
done
echo "Done"
read NUM
let SUM=0;
let I=1
do
I=$((${I} + 1))
done
COUNT=0
for i in 0 1 2 3 4
do
COUNT=$((COUNT + 1))
done