Click Below for Question paper
=== Quetion 1 ===
#!/bin/bash
total=0
regular=0
dir=0
char=0
block=0
symbol=0
ls -p > list
while read fname
do
if [ -d "$fname" ]
then
dir=`expr $dir + 1`
elif [ -f "$fname" ]
then
regular=`expr $regular + 1`
elif [ -c "$fname" ]
then
char=`expr $char + 1`
elif [ -b "$fname" ]
then
block=`expr $block + 1`
elif [ -l "$fname" ]
then
symbol=`expr $dir + 1`
fi
total=`expr $total + 1`
done < list
echo -e "\n\tType of File\t\tNumbers"
echo -e "\n\n\tRegular\t\t\t$regular"
echo -e "\n\tDirectory\t\t$dir"
echo -e "\n\tSymbolic Link\t\t$symbol"
echo -e "\n\tCharacter Special\t$char"
echo -e "\n\tBlock Special\t\t$block"
echo -e "\n\t------------------------------------------"
echo -e "\n\tTotal\t\t\t$total\n"
#!/bin/bash
if [ $# -eq 2 ]
then
no1=$1
no2=$2
if [ $no1 -ge 100 ]
then
echo -en "\n\tFirst number is not of Two digits.\n\tEnter Again : "
read no1
fi
if [ $no2 -ge 100 ]
then
echo -en "\n\tSecond number is not of Two digits.\n\tEnter Again : "
read no2
fi
ans1=0
ans2=0
ans2=`echo "($no1 % 10) * ($no2 % 10)" | bc`
echo "`expr $no1 % 10` * `expr $no2 % 10` = $ans2"
no1=`expr $no1 / 10`
no2=`expr $no2 / 10`
ans1=`echo "($no1 % 10) * ($no2 % 10)" | bc`
echo "$no1 * $no2 = $ans1"
else
echo -e "\n\t----Please pass only two Arguments----\n"
fi
total=0
regular=0
dir=0
char=0
block=0
symbol=0
ls -p > list
while read fname
do
if [ -d "$fname" ]
then
dir=`expr $dir + 1`
elif [ -f "$fname" ]
then
regular=`expr $regular + 1`
elif [ -c "$fname" ]
then
char=`expr $char + 1`
elif [ -b "$fname" ]
then
block=`expr $block + 1`
elif [ -l "$fname" ]
then
symbol=`expr $dir + 1`
fi
total=`expr $total + 1`
done < list
echo -e "\n\tType of File\t\tNumbers"
echo -e "\n\n\tRegular\t\t\t$regular"
echo -e "\n\tDirectory\t\t$dir"
echo -e "\n\tSymbolic Link\t\t$symbol"
echo -e "\n\tCharacter Special\t$char"
echo -e "\n\tBlock Special\t\t$block"
echo -e "\n\t------------------------------------------"
echo -e "\n\tTotal\t\t\t$total\n"
=== Question 2 ===
#!/bin/bash
if [ $# -eq 2 ]
then
no1=$1
no2=$2
if [ $no1 -ge 100 ]
then
echo -en "\n\tFirst number is not of Two digits.\n\tEnter Again : "
read no1
fi
if [ $no2 -ge 100 ]
then
echo -en "\n\tSecond number is not of Two digits.\n\tEnter Again : "
read no2
fi
ans1=0
ans2=0
ans2=`echo "($no1 % 10) * ($no2 % 10)" | bc`
echo "`expr $no1 % 10` * `expr $no2 % 10` = $ans2"
no1=`expr $no1 / 10`
no2=`expr $no2 / 10`
ans1=`echo "($no1 % 10) * ($no2 % 10)" | bc`
echo "$no1 * $no2 = $ans1"
else
echo -e "\n\t----Please pass only two Arguments----\n"
fi

No comments:
Post a Comment