=========================preview======================
(COMP111)midterm-Fall2006.pdf
Back to COMP111 Login to download
======================================================
THE HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY

COMP111: Software Tools

Midterm Exam
Fall 2006
Monday 23 October 2006, 7-9PM



Student Name: ___________key_________________________________

Student ID: _________________________________________________

Lab Section: ________________________________________________


Instructions:

1.
This is a closed-book, closed-notes examination.


2.
Write your name, student ID, lab section, and TA name on this page.


3.
Please circle your answer to make it clear.


4.
Answer all questions in the space provided. Rough work should be done on the back pages.




For Grading Purposes Only:

Problem 1 ______________/ 9
Problem 2 ______________/ 10
Problem 3 ______________/ 8
Problem 4 ______________/ 8
Problem 5 ______________/ 10
Problem 6 ______________/ 13
Problem 7 ______________/ 9
Problem 8 ______________/ 12
Problem 9 ______________/ 11
Problem 10 ______________/ 10

Total: ______________/ 100

1. Unix Utilities [9 marks]

(a)
[2 marks] What command lists the contents of the file named webpage with the first 15 lines skipped?




more +16 webpage OR tail +16 webpage
[-1 mark for +15 instead of +16 in the answer]





(b)
[2 marks] Write a command to rename the file comp000 to comp111




mv comp000 comp111




(c)
[2 marks] What is wrong with the following command?




$ uniq < ufile1 | sort < sfile1

sort has two inputs (from pipe and sfile1)





(d)
[3 marks] Write a command to find the lines in the file fileb which contain the pattern texture, then sort the result, and write the result to a file named filec




grep texture fileb | sort > filec

Marking scheme:
grep texture fileb (1.5 marks)
| sort (1 mark)
> filec (0.5 marks)




2. Unix File System [10 marks]

Assume that the following commands are executed:

$ whoami cschung $ ls -l -rw-r--r-- 1 horner cs 154 Feb 4 16:38 letter1 -rw-r--r-- 1 horner cs 64 Feb 4 15:00 names dr-xr-xr-x 2 horner cs 512 Feb 8 18:01 secret/ $ ls -l secret -rw-r--r-- 1 horner cs 154 Feb 9 17:32 letter1 $ cp names secret/letter1
(a) [2 marks] What happens when these commands are executed?
cp: cannot create regular file 'secret/letter1': Permission denied


(b) [1 mark] Explain what causes any error/warning messages.
Because the user cschung does not have write permission on the file 'secret/letter1'



Assume that the following commands are executed:

$ whoami
cschung
$ ls -l
total 4
-rw-r--r-- 1 cschung cs 29 Oct 11 12:01 letter1
-rw-r--r-- 1 cschung cs 0 Oct 11 12:37 names
d--------- 2 cschung cs 20 Oct 11 12:38 secret
$ ls secret/
ls: secret/: Permission denied
$ chmod u+rw secret/
$ ls secret/

(c) [2