Program 1
WAP to concatenate the contents of 2 files ?
cat first
hai this is first file
ad
cat > second
hai this is Second file
ad
program
viprogt
echo contents of first file
cat first
echo contents of second file
cat second
echo contents of third file
cat first second > third
cat third
esc: x
output
sh progl
Program 2
WAP to Find SUm,AVG,PRODUCT of 4 numbers ?
vi prog2
dear
echo enter A,8,C,D values
reada
read b
read
readd
sum= ‘Expr $a + $b + $c + $d°
Avge “Expr $sum /4°Product= “Expr $a \" $5 \* $c \"@*
echo Sum is $sum
echo Avg is SAVE
echo Products $ Product
escx
output
sh prog2
Program 3
WAP to change two values with out using another variable ?
vi prog3,
dear
echo enter A,B values
reada
read b
echo actual values are A="$a" and B="$b"
“Expr $a + $b’
b="Expr $a-$b*
“Expr $a $b”
echo swapped values are
escx
output
sh prog3
Program 4
WAP to find largest of 3 numbers
vi prog
dear
reada
read b
readif (Sa -gt $b)
then
if [Sa-gt$c]
then echo Sais Bigger
else
echo $cis Bigger
fi
else
if (Sb -gt $c}
then
echo $b is Bigger
else
echo Scis Bigger
fi
fi
output
sh proga
Program 5
Wap to find the Factorial of a given number
vi progs
dear
echo enter the number to get Factorial
while [$n-ge 1]
do
fact “Expr Sfact \* Sn’
n="Expr $n-
done
echo Factorial of Siis $fact
output,sh progs
Program 6
WAP to find the Sum of INDIVIDUAL digits of given numbers
vi progé
dear
echo enter any number having atleast 2 digits
read n
icon
r=0
sum=0
while test $n -gt 0
do
1='Bxpr $n 9610
sum="Expr $sum + $r°
n=Expr $n/10°
done
echo sum of individual digits of $i is $sum
output
sh prog6
Program 7
WAP to find the reverse of a given number
vi prog?
dear
echo enter a number
readn
me
x0
while test $n -gt 0
do
r= Expr $n %10"
xe'Expr $n\"10+ $r°n="Expr $n/10°
done
echo reverse of given number is $x
output
sh prog?
Program 8
WAP to generate fibnacci series
vi progs
dear
echo enter any number
readn
fo=0
fl-1
echo $fo
echo $f
is3
while test $i le $n
do
fi
xpr $fo + $f1"
echo $f2
f0=$F1
Fe Expr Sie?
done
output
sh progs
Program 9
WAP to check whether a given number is PALLENDROME or NOT
vi prog
echo enter any number
readn
x0while test $n -gt 0
do
r= Expr $n%10"
“Expr $x \*10 +r"
n="Expr $n/10
done
if test $x-eq $n
then
echo given number is PALLENDROME
else
echo given number is NOT 2 PALLENDROME
fi
output
sh progo
Program 10
Write a menu Driven Prog
vi prog10
dear
echo "LContents of a FILE"
echo
echo "2.Present Working Directory”
echo
echo "3.XIT"
echo
echo "Enter your Choice"
read ch
case Sch in
Ajecho enter file name
read filename
cat $filename
2)echo present working directory
pwd
3)echo program EXIT*Jecho Incorrect choice
esac
sh progio,
Program 11
WAP to count the no.of UPPER case letters, no.of lowercase letters, no.of digits
and no.of DIGITS and no.of Special characters in a given string
vi progii
dear
echo enter a string
reads
len='echo $5 |we-c*
h=echo Slen-1"
echo length is $h
u=0
feo
d-0
sc=0
while test $n -gt 0
do
a='echo $s |cat-c $n*
case Sain
faz)
[Expr Sr"
(az)
pr Sus”
(0-9})
d="Expr $d+1°
a
apr scl”esac
n="Expr $n-1"
done
echo no.of uppercase letters are Su
echo no.of lowercase letters are SI
echo no.of digits are $d
echo no.of special characters are $sc