Issued on: Friday, January 19, 2007.
Due by: Tuesday midnight, Febury 6, 2007
For this assignment, a paper submission is sufficient. There is no need of an electronic submission. However, you still need an assignment ticket.
Put the assignment ticket and your paper submission in an envelope. The locker of CS211b is 99 at the groundfloor of Middlesex College.
QUESTION 1 (25 marks)
We assume that in our current directory we have a directory called Programs which contains a collection of C programs.
We want to create a new directory structure called Distrib which contains these C programs. The organization will be similar to that of lecture-c-programs that you can download from the course web site: Live C programs used in our lectures. So, this directory Distrib will contain three subdirectories called bin, ps and src together with a file named Makefile. Each of the subdirectories itself will contain files. We assume that:
- the Makefile is located in the directory Programs
- the files that must be be in src are the files in Programs whose names start with a lower case character and which have an extension .c or .h
- the files that must be in bin are the files in Programs whose names start with a lower case character and which have an extension .out
You are asked to write a sequence of shell commands (in tcsh, csh or bash) in order to perform the following actions.
- (A) Create the directory structure Distrib according to the previous specifications.
- (B) In the directory Distrib and in each of these directories create a file called .log which consists of two lines:
- the first one contains the absolute path of this file
- the second one contains the date and time of its creationQUESTION 2 (25 marks)
Explore more commands by yourself. Use man command to learn the command find and grep.
Then help me solving the following problem. On my laptop, I have a collection of directories corresponding to the different courses I have taught or that I am currently teaching. Here's a list of these directories:
AM583      CL2      CS211      CS435      CS545      CS558      CS855      CS874      FTI      Paris6      Yale      APPR      CS210      CS424      CS447      CS556      CS652      CS867      Erable      FTM      SM2      Each directory contains at most 3 levels of subdirectories.
You are asked to write a sequence of shell commands (in tcsh, csh or bash) in order to perform the following actions.
- (A) Find all the files whose names contain marks or grades as a subword, and this search is case insensitive.
- (B) In these files, find all lines containing the name Jeremy
QUESTION 3 (10 marks)
Provide one-line Unix commands to solve each of the following tasks:
- (A) Display a list of all the hidden files in the current working directory, sorted in lexicographical (alphabetical) order of file name.
- (B) Display a detailed directory listing (showing protections, owners, file sizes, etc) for all of the files in the current working directory sorted in order of modification date and time with the oldest file listed first.
QUESTION 4 (15 marks)
Read the man page for the Unix commands script and finger. Then, answer the following questions.
- (A) Use the finger command to find yourself on obelix. What is the one-line Unix command that does this for you?
- (B) Using the echo command, create a one-line file in your home directory called .plan outlining some of your plans for today. Use the command chmod a+r ~/.plan to make it readable to the world. Then, use the finger command as you did from part (A) and capture the results using script. When done, you may remove the file, if you like.
QUESTION 5 (10 marks)
Assume that the following files are in the current directory:
intro      notesb      ref2      section1      section3      section4b      notesa      ref2      ref3      section2      section4a      What one-line commands (including wild cards) can you use to
- (A) list all files whose names begin with section
- (B) list the files section1, section2 and section3 only
- (C) list the files section1, section3, ref1 and ref3
QUESTION 6 (15 marks)
Using echo, give a one-line command which displays the picture on the line following the command.
/ \ / \
\ / \ /