Assignment title: Information
1
Instructions:
All L ATEX files are edited by using vim (or emacs). Your submis- sion include the following two items in a compressed file.
• A PDF file only for Question 1.
• A L ATEX text file for Question 2, 3, 4 and the PDF file gen- erated from the L ATEX file.
Question 1.
Create a L ATEX document, which should be in 11point font
• It contains at least one section and subsection. Include some text in typewriter font, italics, SMALL CAPS and bold.
• Expand the document as follows.
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.
• Expand the document further
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 differ- ent(Don't have to use the multirow package).
3. Typeset the following formulae and add them to the document
x =
−b ±
√
b2 − 4ac
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 Management L ATEX Document Typesetting Package make Managing Project Utility
Table 1: Some Unix Utilities
4. Typeset the following mathematical formula (1).
∆(x) =
1 if x > 0 −1 if x < 0 0 otherwise
(1)
Question 2.
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. The stan- dard comment or commentline 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 state- ments 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. The expected output should look like
printf("It is /* NOT a comment line */\n"); x = 5; /* This is an assignment, not a comment line */
Question 3.
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 4. (20 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 Faculty-Of-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