Shell scripts
Shell scripts
1)
read a b
or
read a b
s=`expr $a + $b`
echo sum=$s
s=`expr $a - $b`
s=`expr $a \* $b`
s=`expr $a / $b`
s=`expr $a % $b`
read a b c
if [ $a -gt $b -a $a -gt $c ]
then
echo $a
elif [ $b -gt $c -a $b -gt $a ]
then
echo $b
else
echo $c
fi
echo -e "MENU\n 1. List of files\n 2. Processes of User\n 3. Today's Date \n4. Users of system\n 5. quit"
read choice
case "$choice" in
1) ls -l ;;
2) ps -f ;;
3) date ;;
4) who ;;
5) exit ;;
esac
4) Factorial
read n
f=1
while [ $n -ne 0 ]
do
f=$(($f * $n))
n=$(($n -1))
done