Osy Output 4 To 15
Osy Output 4 To 15
Roll No- 38
PRACTICAL NO .4
Aim : Run command to start, stop, and restart the specified service in
Linux
Name – Aayush Pandey
Roll No- 38
PRACTICAL NO .5
Aim : Execute process commands - ps, wait, sleep, exit, kill
Name – Aayush Pandey
Roll No- 38
PRACTICAL NO .8
Aim : Execute text processing commands tr, cut, paste, wc, spell ,sort,
grep, more
terminal@terminal ~$ /pnv56/exp8$ cat spell.txt
I studie in Ajeekya DY Patil College
I live in Pune
terminal@terminal ~$ pnv56/expB$ tr "[:lower:]" "[:upper:]"
<spell.txt
I STUDIE IN AJEEKYA DY PATIL COLLEGE
I LIVE IN PUNE
terminal@terminal ~$/ pnv56/exp8$ tr -d "Pune" < spell.txt
tdie in Ajeekya DY Patil College
ive in
terminal@terminal ~$/ pnv56/exp8$
terminal@terminal ~$/ pnv56/expB$ cat name.txt
1 Aayush Pandey
2 Aayush Pandey
3 Aayush Pandey
4 Aayush Pandey
5 Aayush Pandey
terminal@terminal ~$/ pnv56/exp8$ cut -c 1,10 name.txt
1v
25
3h
4
5m
terminal@terminal ~$/ pnv56/exp8$
Name – Aayush Pandey
Roll No- 38
PRACTICAL NO .9
Aim : Use vi editor and perform all editor commands.
Name – Aayush Pandey
Roll No- 38
PRACTICAL NO .10
Aim : Execute Shell Script by using if statement.
Single Decision
echo "Enter percentage here :"
read grade
if [ $grade -ge 90 ] && [ $grade -le 100 ]
then
echo "Grade A"
fi
if [ $grade -ge 70 ] && [ $grade -lt 90 ]
then
echo "Grade B"
fi
if [ $grade -ge 50 ] && [ $grade -lt 70 ]
then
echo "Grade C"
fi
if [ $grade -ge 35 ] && [ $grade -lt 50 ]
then
echo "Grade D"
fi
if [ $grade -lt 35 ]
then
echo "FAIL"
fi
OUTPUT
OUTPUT
PRACTICAL NO .11
Aim : Write and execute Shell Script by using following Control
statements features “for” statement, exit, break, continue.
OUTPUT
terminal@terminal ~$ Desktop/Shell$ chmod ugo+x evenodd.sh
terminal@terminal ~$ Desktop/Shell$ ./evenodd.sh
odd
even
odd
even
odd
even
odd
terminal@terminal ~$ Desktop/Shell$
Name – Aayush Pandey
Roll No- 38
PRACTICAL NO .12
Aim : Write Shell Script to find out whether – Given file exists?
echo "Enter file or directory name"
read file
if [ -f "$file" ]
then
echo "$file It is a file"
else
if [ -d "$file" ]
then
echo "$file It is a directory"
fi
OUTPUT
terminal@terminal ~$ Desktop/Shell$ mkdir ul
terminal@terminal ~$ -/Desktop/Shell$ ls case.sh double.sh
execpwd.sh f
dir.sh evenodd.sh exec.sh file.sh greatest.sh login.sh fibo.sh for.sh
pattern.sh permission.sh single.sh table.sh week.sh lessthan.sh
multiple.sh patt.sh san.sh sun.sh 01
terminal@terminal ~$ /Desktop/Shell$ ./dtr.sh
Enter file or directory name:
U1 ul is a directory
terminal@terminal ~$ Desktop/Shell$ ./dtr.sh
Enter file or directory name:
multiple.sh
multiple.sh is a file
Name – Aayush Pandey
Roll No- 38
PRACTICAL NO .13
Aim : Write a shell script to find out whether - File has read, write and
execute permissions.
echo ―Enter the File : ‖
read line
if [ -r $line ]
then
echo ―$line has all the read permissions‖
fi
if [ -x $line ]
then
echo ―$line has all the execute permissions‖
fi
if [ -w $line ]
then
echo ―$line has all the write permissions‖
fi
OUTPUT
terminal@terminal ~$:Desktop/Shell$ chmod ugo+x permission.sh
utkarsha@utkarsha-VirtualBox:~/Desktop/Shell$ ./permission.sh
Enter the File :
permission.sh
permission.sh has all the read
permissions permission.sh has all the execute permissions
permission.sh has all the write permissions
Write a shell script which displays a list of all the files in the current
directory to which user has read, write and execute permission.
pwd
ls > f
exec < f
while read line
do
if [ -f $line ]
then
if [ -r $line –a –w $line –a –x $line ]
then
echo ―$line has all the permissions‖
fi
fi
done
OUTPUT
terminal@terminal ~$:Desktop/Shell$ chmod ugo+x exec.sh
terminal@terminal ~$:Desktop/Shell$ ./exec.sh
/home/aayush/Desktop/Shell double.sh has all the permissions
execpwd.sh has all the permissions
exec.sh has all the permissions
greatest.sh has all the permissions
login.sh has all the permisstons
multiple.sh has all the permissions
permission.sh has all the permissions
sam.sh has all the permissions
single.sh has all the permissions
Name – Aayush Pandey
Roll No- 38
PRACTICAL NO .15
Aim : Write a ‘C’ program to implement FIFO page replacement
algorithm
#include<stdio.h>
int main()
{
int i,j,n,a[50],frame[10],no,k, Flag,count=0;
printf("\n ENTER THE NUMBER OF PAGES:\n");
scanf("%d",&n);
printf("\n ENTER THE PAGE NUMBER :\n");
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
printf("\n ENTER THE NUMBER OF FRAMES :");
scanf("%d",&no);
for(i=0;i<no;i++)
frame[i]= -1;
j=0;
printf("\tref string\t page frames\n");
for(i=1;i<=n;i++)
{
printf("%d\t\t",a[i]);
Flag =0;
for(k=0;k<no;k++)
if(frame[k]==a[i])
Flag=1;
if (Flag==0)
{
frame[j]=a[i];
j=(j+1)%no; //inc pos
count++;
for(k=0;k<no;k++)
printf("%d\t",frame[k]);
}
printf("\n");
}
printf("Page Fault Is %d",count);
return 0;
getch();
}
OUTPUT