ProgramSolution OS
ProgramSolution OS
sum=$(($a + $b))
echo "Sum of 2 num is : $sum"
// Program:-3
sum=$(($n1+$n2))
minus=$(($n1-$n2))
multiply=$(($n1*$n2))
div=$(($n1/$n2))
echo "Addision = $sum"
echo "Subtraction = $minus"
echo "Multiplication = $multiply"
echo "Division = $div"
// Program:-4
// Program:-6
// Program:-7
while [ $i -le $v ]
do
sum=$(($sum+$i))
i=$(($i+1))
done
echo "Sum of n Natural number: $sum"
// Program:-8
// Program:-9
// Program:-10
// Program:-11
// Program:-12
c=1
while [ $c -ne 6 ]
do
echo "1.. Copy source file to destination"
echo "2.. Rename the specified file"
echo "3.. Print the specified file"
echo "4.. Change permission of specified file to (read,write) for all users"
echo "5.. Display size of specified file in number of character (byte)"
echo "6.. Exit"
echo "Enter your Choice from above:"
read c
echo "Enter file name:"
read f
case $c in
1) read -p "Enter destination directory name:" dn
cp $f $dn
;;
2) read -p "Enter new file name::" nf
mv $f $nf
;;
3) cat $f
;;
4) chmod u+rw $f
ls -l $f
;;
5) wc -c $f
;;
6) exit
;;
*) echo "Wrong choice"
;;
esac
done
// Program:-14
c=1
while [ $c -ne 3 ]
do
echo "1.. List of users who have logged in"
echo "2.. Present work directory "
echo "3.. Exit"
echo "Enter choice from above.."
read c
case $c in
1) #who
z=$(who)
echo "$z"
;;
2) #pwd
z=$(pwd)
echo "$z"
;;
3) exit
;;
*) echo "wrong choice"
;;
esac
done
// Program:-15
// Program:-16
// Program:-17
for file in *
do
if [ -f "$file" ]
then
echo "$file"
fi
done
// Program:-18
for z in */
do
if [ -d "$z" ]
then
echo "$z"
fi
done
// Program:-19
c=1
while [ $c -ne 3 ]
do
echo "1.. ls"
echo "2.. who"
echo "3.. pwd "
echo "4.. Exit"
echo "Enter choice from above.."
read c
case $c in
1) #ls
z=$(ls)
echo "$z"
;;
2) #who
z=$(who)
echo "$z"
;;
3) #pwd
z=$(pwd)
echo "$z"
;;
4) exit
;;
*) echo "wrong choice"
;;
esac
done
// Program:-20
c=1
while [ $c -ne 6 ]
do
echo "1.. Sort the file in ascending order"
echo "2.. Sort the file in descending order"
echo "3.. Sort the file by ignoring case"
echo "4.. Sort the file by avoiding duplication(unique record)"
echo "5.. Count number of words"
echo "6.. Exit"
echo "Enter choice from above"
read c
echo "Enter file name: "
read y
case $c in
1) z=$(sort $y)
echo "$z"
;;
2) z=$(sort -r $y)
echo "$z"
;;
3) z=$(sort -f $y)
echo "$z"
;;
4) z=$(sort -u $y)
echo "$z"
;;
5) z=$(wc -w $y)
echo "$z"
;;
6) exit
;;
*) echo "wrong choice"
;;
esac
done
program-20 computer.lst file
"disk drive"
"memory"
"video memory"
"monitor"
"tape drive"
"CD-ROM"
"modem"
"monitor"
"sound laster"