Sei sulla pagina 1di 3

FEE 281 COMPUTER SCIENCE LABORATORY SECTION

GROUP C
SHELL SCRIPT EXERCISE
BRIEF:
This laboratory exercise segment will be part of the grade for the unit FEE
281.
The exercise consists of five questions involving writing solutions using shell
scripting and command line concepts.
Answer all the questions.
Deadline: 12th February 2015

INSTRUCTIONS:
The laboratory work must have the following format and follow the following
rules:
1. A Title Page indicating Student name, Student Registration Number,
Group Designation (A, B, D or C) and Submission Date
2. A group has a maximum number of 2 individuals. Group members
details should be on the Title page only.
3. A Body that is a minimum of 3 pages in length, excluding the Title
Page.
4. All parts of the report/exercise must be handwritten.
5. Copied work will not be tolerated. Be as unique as possible.
6. Marks may be awarded for clarity of presentation and expression.
7. Submit your work only using A4 single ruled paper (you may
choose to use either standard ruled 32 lines or narrow ruled 70
lines)
Marks will be deducted if the aforementioned rules are not adhered to.

QUESTION 1 (4marks)

Create a text file called bio.txt using the gedit editor


Store your name, registration number, gender and height in the file info.txt
Create a script file called scriptQ1.sh that outputs the date and the contents
of info.txt onto the terminal screen. The date and the contents of bio.txt
should be separated by a double line of appropriate length
Write out scriptQ1.sh and the output seen on the terminal screen

QUESTION 2 (4marks)

Create a text file called names.txt


Store the following names in the following order:
o Mary
o Jones
o Abednego
o Quentin
o Margo
o Cyril
Create a shell script called scriptQ2.sh that sorts the above names both in
ascending and descending order. The same script should then store the
sorted names into a new text file called sorted.txt
Write out names.txt, scriptQ2.sh and sorted.txt

QUESTION 3 (4marks)

Create a shell script called scriptQ3.sh that does the following when
executed:
o Asks the user to input two integral numbers
o It calculates the sum, difference, multiplication and quotient of the
above user generated numbers
o It has the four results displayed on the terminal screen
Write out scriptQ3.sh

QUESTION 4 (2marks)

Make use of the file names.txt from Question 2 above


Create a shell script called scriptQ4.sh that does the following when
executed:
o Makes a directory called CSClub
o Creates a file within CSClub called Members containing the names
from names.txt
Write out scriptQ4.sh

QUESTION 5 (6marks)

Create a shell script called scriptQ5.sh that does the following when
executed:

o
o
o
Write

Asks the user to enter name of a file or directory in the current


directory
Outputs whether the name input is a file or a directory or inconclusive
Outputs whether the name input has or lacks read access for the user
Outputs whether the input has or lacks write access for the user
out scriptQ5.sh

Potrebbero piacerti anche