In this assignment, you will demonstrate some basic Unix commands by
performing some simple tasks. To begin this assignment,
look at the files located
in the ~cs155/pub/hw2Files directory. The files contain
information about people. For each person there are four files.
For example, Sam would have the following four files:
sam.grades ;).sam.info sam.jpg sam.log Your primary objective in this assignment is to use your knowledge of Unix commands to collect and manipulate data contained in these files. For each of the problems listed below, you should give the command(s) you used. I want to see the commands, not the output of those commands.
Place your answers in a file named people, and submit it for HW2.
It must not be called “hw2”. You may use pico to generate your
submission, or any other editor that you prefer. Your submission should
be formatted as follows, with blank lines between parts:
1
command
command
2
command
command
3
command
4
... etc.
This time the grading is a little different: The difficulty of the questions vary. Some problems require multiple steps and some require complex commands. Each problem specifies a number of commands; you will be penalized for submitting an answer that uses more commands than were specified.
cat foo
cat foo | cut -c' ' -f 2 | sort
cat foo; date
cat foo
date
Unless otherwise specified, assume that you start this assignment in your home directory. Assume that after each question you return to your home directory. A few of these problems will require some thought. Try to break the problems into individual commands and test out your ideas before assembling commands together. Good luck.
.info OR .log?)
lousy in your home directory that contains the
file names and lines (the data, not the line numbers) in those files
where students scored less than ten out of a hundred.
brain in your home directory.
Copy all info files into this directory.
~cs155/pub/hw2Files/ directory.courses in your home directory with a list of all
the courses taken by anyone (e.g. courses listed in all grades files).
Look at the manual page for cut, and be sure to use quotes on your delimiter.courses,
just display the results.
earlybirds in your home directory with a listing of all people who logged in on January 3rd 2006.
.log files and search for anyone with an entry
for the date specified.
cut command in more detail
to get just the name.
~cs155/pub/hw2Files directory. log.info in your home directory containing two
columns, where the first column is the number of times the person
has been logged and the second column is the person’s name
(use cut to remove the .log from the output). 42 total.
(Hint: You will need to consult the cut and sort man pages for
this problem.)
The output looks like this:
1 jane
1 jill
1 matilda
1 mati
1 sally
1 sam
1 wilma
3 fred
3 george
4 alex
7 gerry
7 jack
11 mary
42 total
It doesn’t matter whether mati or matilda comes first.
man to get information on commands.
Some problems require command options we may not have covered
in depth during class.
~)
and not some giant hideous path that starts with /s/.
If you use a giant hideous path instead of using tilde, you will
lose points. This means that you have to use quotes properly.
Consider this, which produces bad results in the file x,
and good results in the file y.
% echo Go home: cd ~ >x % echo "Go home: cd ~" >y % cat x Go home: cd /s/parsons/d/fac/applin % cat y Go home: cd ~
jack.log,
it would not be acceptable to cat jack.log, look at the results,
count the lines on your fingers, and then turn in the command echo 7.
Yes, that command produces the same results, but that command doesn’t
actually do the counting—you did.
Did you call your file people? If you call it “hw2”, you’ll lose points.
Follow the directions on the homework page.
Turn in someone else’s work.