Technical Communications in the Unix Environment
SESSION 3 HOMEWORK [by Bruce Overby]
You'll have to log onto the Lanminds server to complete this
homework. It involves manipulating files I've placed in each of your home
directories on the server.
-----------------------------------------------------------------
The Scenario:
Now that you have gotten through the UCB Extension Technical
Communications program, you are a totally kick-ass tech
writer! As such, you routinely crank out brilliant stuff, and
your latest triumph is an article on XML titled "XML and the
Second-Generation Web," which is about to be published by
Scientific American. You've arrived at work and realize you
have some housecleaning to do on the directory you created
for this article. You've decided to brush up on your Unix
command-line chops and, for the moment, set aside your
elegant Solaris GUI.
The Steps/Questions:
1. Go to your home directory. There you will find a new
directory called WorkSession3.
2. Now cd into the WorkSession3 directory and examine its
contents, particularly the README file. Answer the
following questions.
a) If you had some sample JINI application code, where
would you put it?
__________________________________________
b) If you had an online copy of an article on Unix, where
would you put it?
__________________________________________
c) If you were going to work on your XML article, which
directory would you cd to next?
__________________________________________
3. Using vi, edit this README file, replacing the string
"UserID" with your user ID.
4. Now cd to the
XML.article directory, which contains the following files:
1_Beginning.txt
1_Beginning.txtL
2_SomethingOld.txt
2_SomethingOld.txtL
3_AnEnd.txt
3_AnEnd.txtL
4_SomeAssembly.txt
4_SomeAssembly.txtL
5_AQuestion.txt
5_AQuestion.txtL
README
5. View the README file in this directory and briefly describe
what the contents of the directory are:
__________________________________________
6. Using the more command, view the contents of
1_Beginning.txt.
7. Now do the same with 1_Beginning.txtL. Do you notice any
difference between the contents of the two files?
___ No
___ Yes (Explain:
____________________________________________________)
8. To get more detail on these files (and because your manager
is going to want to know exactly how much work you've done
on this article), check the word, line and character count
for each and write the data in below:
1_Beginning.txt (_____ lines; _____ words; _____)
1_Beginning.txtL (_____ lines; _____ words; _____)
9. Feel free to examine the files further. To what do you
attribute the differences (both large and small) in the
counts? (Feel free to just take a guess on this one.)
__________________________________________
10. It turns out the reason your production guy created an
extra, sligthly different version of each file because
these files are going to be sent directly to the printer
via ftp, and he wasn't sure what type of file the printer
needed. He now knows, and he just came in and told you
you're not going to need the versions that end with ".txt."
The printer will use the ones ending in ".txtL." To
maintain a clean directory and preserve disk space, do the
following:
a) Remove all the files ending in ".txt." For extra credit,
complete this step with a single Unix command line, and
without typing in each file name individually. (Hint:
This will require the use of a wild card character.)
What is the Unix command for removing files? _____
If you did this step with a single command, what was the
full command line you used? __________
b) Edit the README file using vi. Remove references to the
deleted files.
11. It turns out I was correct about your manager. She wants
to know how much you've accomplished, and three of her
measuring sticks are line, word, and character counts. She
wants you to create a file called "counts" showing the
line, word, and counts for all the files in your article.
Construct a single Unix command that will:
a) Determine the line, word, and character counts for all
the files in the directory (including the README file).
b) Redirect this output into a file called "counts."
This will allow your manager to peruse this directory later
and review your work.
What command did you use?
____________________________________________
12. View the file, counts and answer the following:
a) How many total lines of text are there in these files?
_____
b) How many total words? _____
c) How many total characters? _____
13. You know your manager, and as you look at the file,
counts, you know she won't be happy with it as is. Using
vi, edit this file and add the following:
a) The title: "Word Counts: Totally Rockin' XML Article"
b) Column heads for each of the four columns in the file.
c) An blank line to separate the main counts from the last
row in the columns, which lists the totals.
View the file named counts to check your work.
14. Your manager, not surprisingly, has changed her mind.
She's decided she doesn't want to have to look at two
different files, README and counts, to get information
about this project. She'd like the counts information
appended to the bottom of the counts file.
Construct a single Unix command that will:
a) Send the contents of the file named counts to the
standard output.
b) Append this output to the file README.
What command did you use?
____________________________________________
View the README file to check your work.
15. Now that your counts information is in your README, you
no longer need the file named counts. Remove it.
16. Using vi, edit the README to make any subtle formatting
changes needed, now that you've appended information to the
end of it.
17. Now the production guy is back, and he's telling you
he'll be ready to send the files to the printer this
afternoon. As such, though he knows you like to work with
individual files for each section of your totally awesome
award-winning articles, he'd really appreciate just having
one file for the whole article. You gladly agree, since
you're busy sharpening up your Unix command line chops
today anyway.
Construct a command that will do the following:
a) Send the contents of the all the files comprising your
article (those ending with a ".txtL" suffix) to the
standard output.
b) Redirect this output to a file called FullArticle.txt.
For extra credit do this with a single Unix command, and
without typing in each file name individually. (Hint: This
will require the use of a wild card character.)
What is the Unix command for sending a file's contents to
the standard output? _____
If you completed this step without typing each file name
individually, what was the full command line you used?
__________
18. Using vi, edit the README to account for the new file.
(Don't worry about including the word count for
FullArticle.txt in your listing at the end of the file.)
19. You are now finished with your work in the
WorkSession3/XML.articles directory. Now move up one level
to the WorkSession3 directory.
What command did you use?
____________________________________________
20. View the contents of this directory using the ls
command.
What command did you use?
____________________________________________
21. Now view the contents as a single column.
22. As you view these contents note that the subdirectories
in this directory are named so they appear in topical
groupings (all the JINI-related subdirectories together,
all the Unix related subdirectories together, etc.) In
polishing up your Unix chops today, you realize that these
subdirectories would be much easier for you to work with if
they were organized based on the file types of their
contents (articles, resources, samples), rather than the
topic they cover.
Rename all of these directories so that those containing
articles will appear together, those containing resources
will appear together, and those containing samples will
appear together. (This will require several command lines.)
23. Now view the contents as a single column.
24. Now append this single-column listing to your README
file.
25. Using vi, edit the README file to account for the new
naming scheme.
26. You are now finished with your cleanup at this level,
and there's a little task to do in the directory containing
Unix information resources. Using the cd command, go to
this directory and list the files.
27. Take a quick look at the README to see where you are and
what's here.
28. View the contents of the file named command.synopses. In
it, you should see a two-column listing of user- and
administrator-level Unix commands.
29. Because the bonehead who gave you this resource had
assembled it in a rather random fashion, the commands are
not listed alphabetically, which would make the file much
more useful. Construct a single Unix command line to:
a) Sort the contents of command.synopses and send the
sorted list to the standard output.
b) Redirect this output to a file called commands.sorted.
View the new file to check your work.
30. Using vi, edit the README file to account for the newly
added file.
When finished with this homework, do not delete the
WorkSession3 subdirectory from your directory.