Assessments As there are 3 assignments you must complete them in a timely manner. In particular, you must ensure that you install Linux early in the semester so that you can proceed with the assignments. What and how to hand in All assignments are to be submitted in an electronic (not paper) format. On-campus students must submit assignments via EASE on your StudyDesk. External students are allowed to use a CD-R disk to do so if and only if online submission is not possible. The ‘submissions’ page contains complete instructions for submitting an assignment. Before the due date, you will be able to submit an assignment via EASE as often as you like. A newer submission overwrites the older one, hence only the most recent one will be marked. Penalties will apply for late submissions (see the course specification). As an alternative for external students only, submit files on a CD-R, using normal mailing procedures. The Linux tool for generating an ISO9660 filesystem (the filesystem found on optical disks) and burning it to disk growisofs Do not submit via email. Submissions via email will be ignored! Each assignment consists of completing a number of questions. Typically you will be asked to hand in either or both of the following: • A text file showing that you have executed correctly the commands or programs that are described in the exercises. • One or more program files or scripts (e.g. makefile, Bash script, Latex source or output). Here is a good way of creating the assignment text file (the first of the two items above). This is especially recommended for the first assign-ment. Have two terminal or windows open on your screen. One is a standard window used to type in the commands and inspect the result. The second one contains an editor session. Now try out the commands needed for the assignment in the first window; when you get it right highlight (click anddrag the left mouse button) the command and its response. Then paste into the editor session using the middle mouse button. If the text you want to highlight is longer than a screenfull either copy and paste a screenfull at a time or do the following to highlight it (we assume a three button mouse) before a single paste operation. • Scroll up in the window using the middle mouse button while pointing at the scroll bar. • Highlight the initial part of the text by click and dragging with the left mouse button. • Scroll down to the end of the text to be selected. • Extend your initial selection by click and dragging the right mouse button. How to Lay Out Assignments Suppose Question 3 in Assignment 1 is What is inode?, your answer to it should indicate clearly which question using some suitable marker like ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Question 3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ inode is a data structure that contains information about a file. An inode for a file contains the file’s length, the times the file was last accessed and modified, ...... It is vitally important that your assignment is clearly laid out. It must be a straightforward matter for the examiner to deter-mine that you have completed each question satisfactorily. We want quality not quantity. Poorly organized submissions will be rejected.Assignment 2 Weight 20% Due Date See course specification Submission instructions question 1 to 4: Your submission should be a single archive file, and preferably compressed as well, which contains the following 4 files : • A text file contains the script for question 1. • A text file contains the answer for the question 2. (Hints: to fully understand the script, you are advised to type in the given script using vi editor, and make it executable and test it). • A text file contains the answers for question 3. • A makefile workable for question 4. • A text file contains all the RCS commands you use . The utility to use is tar ass2.tar file1 [file2 ...] Question 1. (10 marks) Write a well structured Bash script to delete comments from a C program. In Bash script, you may use sed commands or other Linux utilities. A standard comment line in C programs starts with the two-characters token (/*) and ends with the two-character token (*/). Assume that each comment line contains the start and end tokens without any other statements before and after. You need to pay attention to the following cases: /* a comment line in a C program */ printf("It is /* NOT a comment line */\n"); x = 5; /* This is an assignment, not a comment line */ [TAB][SPACE] /* another empty comment line here */ You can test your Bash script on a C program containing all above four lines.Question 2. (15 marks) A Bash script is given as follows. #!/bin/bash #A script demonstrating an until-loop and command line processing # # List the regular files of a directory greater than a given size name=${0##*/} Usage="Usage: $name [-h] [-s N] [directory]" if [ $# -eq 0 ]; then echo $Usage exit 1 fi until [ $# -eq 0 ] do case $1 in - s) shift size=$1 shift;; -h) echo $Usage exit 0;; *) directory=$1 shift;; esac done directory=${directory:-‘pwd‘} if [ ! -d $directory ]; then echo "‘$directory’ is not a directory" exit 1 fi arg=’’ if [ $size != ’’ ]; then arg="- size +$size" fi find $directory $arg -type f -exec ls -l {} ’;’Carefully look at it. Add comments to this script — line by line. Question 3. (10 marks) In the makefile below which has some implicit rules, first identify all of: • targets • construction commands • dependencies • macros Then replace the implicit rules by the explicit rules. COBJECTS = menu.o users.o resellers.o propspects.o HFILES = menu.h leads: $(COBJECTS) gcc -o leads $(COBJECTS) menu.o users.o resellers.o prospects.o: $(HFILES) Question 4. (15 marks) Suppose there are two C source (transaction.c and reports.c) and two header files (trans.h and reps.h). Write explicit rules for a Makefile/makefile that reflects the following relationships: 1. The C source files transaction.c and reports.c are compiled to produce an executable accts. 2. transaction.c and reports.c include a header file accts.h 3. The header file accts.h is composed of two other header files: trans.h and reps.h.Submission Instructions for questions 5 to 8: Submit a single tar file, preferably compressed, which contains: • A single text file contains the script for question 5. • A set of L A TEX files as suggested in question 6. • A L A TEX file as suggested in question 7. Question 5. (10 marks) Write a short but well structured Bash script that, given the name of a file as an argument, reads the file name and creates a new file containing only those lines which have one word in it. Here is an example of the input file. This is a special text file There are 20 students in the class. [TAB][SPACE] Nearly half of them are enrolled in FoS. The rest are in FacultyOf-ES. The output file from the script should look like There [TAB][SPACE] Nearly Faculty-Of-ES. Ensure the script has error and robustness checking. Question 6. (10 marks) Use a small text file to experiment with the RCS system. Note that RCS treats all ASCII file the same way; the files do not necessarily be programs, though usually are programs. Specially you should • Place a $Log$ keyword in the file • Complete a set of check in operations which result in the RCS file structure depicted in Figure 1.2.2 2.1.1.1 1.2.1.2 2.1 1.2.1.1.1.1 1.2.2.1 1.2.1.1 1.2 1.1 Figure 1: You will need to make small changes to the source file between check in operations. • Associate a symbolic name with revision 2.1.1.1 • Make the branch containing revision 2.1.1.1 the default branch • Use rlog to verify the RCS structure. Give all the command lines used in each step along with a brief description. Question 7. (10 marks) You need to submit two separate L A TEX documents. • Create a short (less than 1 page) L A TEX document. It should be in 11point font, and contain at least one section and subsection. Include some text in typewriter font, italics, SMALL CAPS and bold. (Please save the document as ar0.tex ) • Expand the document as follows. (Please save the expanded document as ar1.tex )1. Add a title with your name and the date 2. Include at least two forms of list 3. Include a piece of verbatim text – this might be a program or a program fragment. 4. Experiment with font size: try out all (at least 4) the available font sizes and include the results in your document. Ensure the L A TEX document has an appropriate structure and L A TEX tags are in right order. Question 8. (20 marks) Expand the document: ar1.tex as follows. (save this document as ar2.tex) 1. Add a table of contents 2. Create a floating table with caption. It should look just like the one in Table 1, except that the table number will be different(Don’t have to use the multirow package). Category Tool Command Description Editor emacs Emacs extensible text editor vi Visual editor Scripting bash GNU Bourne-Again SHell perl Practical Extraction and Report Language Document rcs Revision Control System A Management LTEX Document Typesetting Package make Managing Project Utility Table 1: Some Unix Utilities 3. Typeset the following formulae and add them to the document x = −b ± √ b2 −4ac 2a 4. Typeset the following mathematical formula (1). 1 if x > 0 Δ(x) ={ −1 if x < 0 (1) 0 otherwise