207 Assignment Instructions (for
typical assignments)
- It is important to make sure you understand the tasks asked
for in a given assignment. Asking for clarification during class period
is the proper way to approach such questions.
- The list of tasks associated with an assignment may grow up
until a week prior to its due date. Do not assume that the first posted
version of an assignment will be the final version. The reason for
this: I like to let people know what is coming so that they may get an
early start on the assignment. Changes that may occur will consist of
clarifications (if ambiguity in the assignment is discovered) or the
possible addition of extra tasks.
- Format for handing in assignments: Copy all
questions (tasks) into a text file. Type (or paste session logs that
represent) your answer below each question. Print the finished
assignment on paper
to be handed in.
- For each question it is expected that you show the steps
you used to complete the task as well as the step-by-step responses
provided by the operating system to your own steps. You
should also demonstrate that your commands have accomplished what was
intended by checking to make sure the results are correct; include
evidence of this verification of correctness.
- You should not include false starts, error messages and
general floundering but merely the commands which fulfill a particular
exercise, and a demonstration of the feedback received.
- Don't hand your work in until you have done all that you
intend to. That might imply keeping backups of your work in case of
system failure.
Illustrative examples
Here's a pretend assignment:
-------------------
Assignment #79
1.
In a file that has two columns of data (separated by one or more space
characters), show commands which succeed in reversing the order of the
columns (while keeping the data intact within each column).
2.
The file /home/SRUNET/david.dailey/words consists of several words,
alphabetized, with one word per line, find all pairs of words for which
both are words and for which the first word is the same as the second,
but reversed. How many pairs of such words are there in
/home/SRUNET/david.dailey/words?
-------------------
-------------------
Here's what your work (printed on paper for submission) might look like:
Assignment #79 -- submitted January 15 by Jambalaya Fishborne.
1. In a file that has two columns of data
(separated by one or more space characters), show commands which
succeed in reversing the order of the columns (while keeping the data intact within each column).
My original file (consisting of two columns of character data):
$cat temp
ag ms
bh nt
ci ou
dj pv
ek qw
fl rx
Reversing the order of the columns: command and output
$awk '{print $2, $1}' temp
ms ag
nt bh
ou ci
pv dj
qw ek
rx fl
2. The file /home/SRUNET/david.dailey/words consists of several words,
alphabetized, with one word per line, find all pairs of words for which
both are words and for which the first word is the same as the second,
but reversed.
The command I used to dump the words into a file (named backward):
for i in `cat words`; do echo -e $i"\n"`echo $i|rev`; done|sort|uniq -d>backward
The first and last five words in backward (output side-by-side to save paper):
$paste <(head -5 backward) <(tail -5 backward)
a yam
abba yap
abut yard
aga yaw
ah yob
Demonstrating that these all remain words, when reversed. First, consolidating the words with their reversals:
~$for i in `cat backward`; do echo $i `echo $i|rev`; done|head
a a
abba abba
abut tuba
aga aga
ah ha
aha aha
alula alula
ana ana
anal lana
animal lamina
~$for i in `cat backward`; do echo $i `echo $i|rev`; done|tail
wolf flow
won now
wop pow
wot tow
x x
yam may
yap pay
yard dray
yaw way
yob boy
Second: demonstrating that the reversal of each word is, in fact, in the file backward:
~$for i in `cat backward`
> do
> grep ^$i$ backward
> done|wc
282 282 1266
~$wc backward
282 282 1266 backward
2. How many pairs of such words are there in /home/SRUNET/david.dailey/words?
Answer: 282 pairs of words (564 words, with each word counted twice):
~$for i in `cat backward`; do echo $i `echo $i|rev`; done|wc -lw
282 564