Professional Documents
Culture Documents
:
:
:
:
:
:
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]
[2]
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.
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
#!/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]
Uploaded by
Mobile Number
Email
:
:
:
SNUPA AKASH
9539195991
snupakp853@gmail.com
[5]
for
PART-II: MCS-043
Coming soon on www.myignou.in
[6]