0% found this document useful (0 votes)
397 views

MCSL-045 Solved Assignments 2014-15

This document contains solved assignments for the 2014-15 academic year for the MCSL-045 UNIX and DBMS LAB course. It provides information on the course code, title, assignment number, marks, weightage, and due dates. The assignment has two parts - Part I focuses on UNIX commands and includes writing shell scripts to perform arithmetic operations and search arrays. Part II will cover DBMS topics but is not included. The document provides detailed responses to questions on UNIX commands and shell scripting examples.

Uploaded by

manish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
397 views

MCSL-045 Solved Assignments 2014-15

This document contains solved assignments for the 2014-15 academic year for the MCSL-045 UNIX and DBMS LAB course. It provides information on the course code, title, assignment number, marks, weightage, and due dates. The assignment has two parts - Part I focuses on UNIX commands and includes writing shell scripts to perform arithmetic operations and search arrays. Part II will cover DBMS topics but is not included. The document provides detailed responses to questions on UNIX commands and shell scripting examples.

Uploaded by

manish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Visit www.myignou.in for more solved assignments!

MCSL-045 Solved Assignments 2014-15


Presented by www.myignou.in
Course Code
Course Title
Assignment Number
Maximum Marks
Weightage
Last Dates for Submission

:
:
:
:
:
:

MCSL-045
UNIX and DBMS LAB
MCA (4)/L045/Assign/2014-15
100
25%
31st October, 2014 (For July 2014 Session)
30th April, 2015 (For January 2015 Session)

The assignment has two parts A and B. Answer all the questions. Each part is for 20 marks.
UNIX and DBMS lab record carries 40 Marks. Rest 20 marks are for viva voce. You may use
illustrations and diagrams to enhance the explanations. Please go through the guidelines
regarding assignments given in the MCA Programme Guide for the format of presentation. If
any assumptions made, please state them.

PART-I: MCS-041
Question 1: Write the UNIX commands for the following:
a) Use the cat command, and display all the .txt files in the current directory on the
screen at one go.
Command: cat *.txt
b) To copy dir1 into dir2 including subdirectories.
Command: cp -r /dir1 /dir2
c) To start any web browser from the command prompt.
Command: xdg-open filename_or_URL
d) To search for a certain pattern in the files existing in the current directory
Command: The grep utility searches the contents of one or more files for a
pattern.
The format is:
% grep [<options>] <pattern> [<file> ...]
Some of the options are:
-c
Display only a count of lines that contain the pattern.
-i
ignore upper/lower case distinctions during comparisons.
-l
Display only the name of each file that contains one or more
matches.
e) To list lines that do not include and in a text file.
Command: grep -v "and" filename
f) To compress all .dat files in the current directory.
Command: gzip *.dat
[1]

Visit www.myignou.in for more solved assignments!

g) To decompress all the .dat files compressed in (f).


Command: gunzip *.dat.gz
h) To pause a process.
Command: kill -STOP 667
# pause (stop) process with id 667
i) To kill a process.
Command: kill -9 667
# Which should kill process with id 667
j) To send a set of files to the line printer.
Command: lp filename
Or
lpr filename
k) To list all the files in the present working directory including the hidden files.
Command: ls -al
l) To show all the files in the subdirectories of a directory.
Command: ls -R
m) To get help on any UNIX command.
Command: man any_unix_command
n) To display any file one screen at a time.
Command: more [options] [files]

[2]

Visit www.myignou.in for more solved assignments!

Question 2:
a) Write a shell script program to perform all Arithmetic Operations using
Command line arguments.

read a
echo Enter the number
read b
c=`expr $a + $b`
echo Addition= $c
d=`expr $a - $b`
echo subtraction=$d
e=`expr $a \* $b`
echo Multipliccation=$e
f=`expr $a / $b`
echo Division=$f
o/p
Enter the number
4
Enter the number
2
Addition=6
Subtraction=2
Multiplication=8
Division=2

b) Write a shell script program to search whether element is present in the list or
not and also display its position in the list.

echo Enter array limit


read limit
echo Enter elements
n=1
while [ $n -le $limit ]
do
read num
eval arr$n=$num
n=`expr $n + 1`
done
echo Enter key element
read key
[3]

Visit www.myignou.in for more solved assignments!

low=1
high=$n
found=0
while [ $found -eq 0 -a $high -gt $low ]
do
mid=`expr \( $low + $high \) / 2`
eval t=\$arr$mid
if [ $key -eq $t ]
then
found=1
elif [ $key -lt $t ]
then
high=`expr $mid - 1`
else
low=`expr $mid + 1`
fi
done
if [ $found -eq 0 ]
then
echo Unsuccessfull search
else
echo Successfull search
fi

c) Write a shell program to illustrate the case statement.

#!/bin/bash
# if no command line arg given
# set rental to Unknown
if [ -z $1 ]
then
rental="*** Unknown vehicle ***"
elif [ -n $1 ]
then
# otherwise make first arg as a rental
rental=$1
fi
# use case statement to make decision for rental
case $rental in
"car") echo "For $rental rental is Rs.20 per k/m.";;
"van") echo "For $rental rental is Rs.10 per k/m.";;
"jeep") echo "For $rental rental is Rs.5 per k/m.";;
[4]

Visit www.myignou.in for more solved assignments!

"bicycle") echo "For $rental rental 20 paisa per


k/m.";;
"enfield") echo "For $rental rental Rs.3 per k/m.";;
"thunderrbird") echo "For $rental rental Rs.5 per
k/m.";;
*) echo "Sorry, I can not get a $rental rental
you!";;
esac

Uploaded by
Mobile Number
Email

:
:
:

SNUPA AKASH
9539195991
[email protected]

[5]

for

Visit www.myignou.in for more solved assignments!

PART-II: MCS-043
Coming soon on www.myignou.in

[6]

You might also like