Вы находитесь на странице: 1из 16

1.Create a file student.

dat with the following fields


Field Name
Datatype
Value
Student Code
alphanumeric
Student Name
character
Batch Code
character
Batch I,Batch II
Course
character
MCA,MMS,MBA
Percentage
numeric
Insert at least five records. Fields are separated by ":"
Write a command for the following.
{
Here 5 data are inserted

a. Display the details of student in order of their name ignoring case.


{ cut d : f 2- student.dat }

b. Count the number of students who belong to Batch I irrespective of the


course
{grep c batch1 student.dat}

c. Store the list of first 3 rank holders for MCA course in merit.dat file
{ sort t : r k 5 student.dat | head -3 >marit.dat }

a. Display record of students who have not taken the course MCA
{ grep v MCA student.dat }

e. Count the number of students in student.dat file.


{ wc l student.dat }

f.List the student name in order of course.


{ sort t : k 4 student.dat | cut d : f 2 }

g. Display student name along with course and percentage.

{ cut d: f 2,4- student.dat }

h. Display records where course name is "MCA" or "MBA".


{ grep e MCA e MBA student.dat }

Question 2:

2. Consider the following file structure for product.dat .Field separator is |

Product id
Product name
Quantity in hand
Price per unit
a. Display the information of products with name dove and lux
{ grep edove elux product.dat }

b. Display product name along with quantity in hand < 50


c. List the product ids where price per unit is in between Rs. 10 to Rs. 50
d. Display products with id as P101 and P103
Insert some duplicate rows. Write and execute commands to perform the
following:
{ grep e p101 ep103 product.dat }

e. Display lines that are unique


{ uniq product.dat}

f.Count the no.of occurrance of each line


{ uniq c product.dat }

a. Replace the field seperator | with * tr


{ tr | * < product.dat }

Question 3:

3. Create a file empdata.dat , containing the following fields


Field Name
Datatype
Value
Employee code alphanumeric
E001
Employee name numeric
Department code
character
MKT,HRD,PUR
Grade
character
A,B,C
Experience
numeric
-

Basic pay
numeric
Insert at least five records in empdata.dat . Fields are separated by "-"
Write a command for the following.
a. Display all employees who are in department MKT
{ grep MKT empdata.dat }

b. Sort empdata.dat on department code and grade


{ sort t - k 3 k 4 empdata.dat }

c. Display the name of the employee with the highest basic pay
{ sort n t - k 6 empdata.dat |tail -1 }

d. Display details of Employee with least experience


{ sort n t - k 5 empdata.dat | head -1 }

Question 4

4. Create a file item.dat with the following fields having the mentioned type
of values

Field Name
Data Type
Item code
Numeric
Item name
Character
Price
Numeric
Quantity
Numeric
Insert at least five records in item.dat . Fields are separated by ":"
Write a command for the following.
a. Sort items according to their prices
{ sort n t : k 3 item.dat }

B Display record of the item with the highest quantity


{ sort n t : k 4 item.dat | tail -1 }

C Sort the records according to their names in descending order


{ sort r t : k 2 item.dat }

D Display the records where the item name begins with "P"
{ cut d : f 2- item.dat | grep ^p }

e. Display the record of the item with the least price


{ Sort r n t : k 3 item.dat |head -1 }

6. Create files f1,f2 and f3, where f1 contains names of courses offered by
college A, f2 contains names of courses offered by college B, f3 contains
names of courses offered by college University.
Write a command for the following :
a. Count the number of courses offered by University

B .Display the list of courses offered by University, but not offered by college A

C Display the list of common courses offered by college A and B

D Display the list of courses offered by college A, but not offered by


college B

Question 7

7. Create files f1, f2 and f3, where f1 contains names MCA colleges in
Mumbai, f2 contains names of MCA colleges in navi mumbai and f3 contains
names of MCA colleges that participated in St.Marys techfest.
a. Count the number of colleges in Navi mumbai.

b. Display college list from Navi Mumbai who participated in techfest

c. Display college list from Mumbai who did not participate in techfest.

d.Merge the Mumbai and Navi mumbai colleges in file colleges.dat

e.Count total number of MCA colleges

Question 5

5. Create a file student.dat with the following fields separated by ":" having
the below mentioned fields
Field Name
Data Type
Roll No
Numeric
First Name
Character
Last Name
Character
Date of Birth
dd-mm-yyyy
Marks out of 600 Numeric
Grade
character (A,B or C)
Insert at least 5 records and write a command for the following :
a. Sort the data on first name only

b. Sort the data on marks only


{ sort n t : k 5 student.dat}

c. Display the first name of the student with the lowest marks
{ sort n t : k 5 student.dat |head -1 }

d. Display the date of birth in dd/mm/yyyy format


{ cut d : f 4 student.dat |tr - / }

e. Count the number of students with unique name.


{ uniq student.dat |wc l }

f. Display student name along with ascending order of marks.


{ sort n t : k 5 student.dat | cut d : f 2,5 }

g. Display students name in descending order.


{ sort r t : k 2 student.dat | cut d : f 2 }

h. Display students with name "neha" .

k.Find data of students with last name Patil .


{ grep Patil student.dat }

. Find students with A and B grade


{ grep e A$ -e B$ student.dat }

m. Count the no.of students with C grade


{ grep C$ student.dat |wc l }

n. Sort students in descending order of their roll nos


{ sort nr t : k 1 student.dat }

Вам также может понравиться