IT244: Introduction to Linux/UNIX – Fall 2010 Homework 6

advertisement
IT244: Introduction to Linux/UNIX – Fall 2010
Homework 6
Due: Monday, 12/13/2010
Chapter 10:
NOTE: For all scripts that you are asked to write or work with, please
make sure that you write a script on Linux (sf05.cs.umb.edu) and test it.
NOTE: Answering the first six questions correctly will give you 100%
on this homework. Questions 7-9 are designed to help anyone needing
to bring up their grade in this course. If you complete all 9 questions
correctly, you can get 200% for this homework. When averaged against
all your other grades, this should help you out. Be very careful to
answer everything completely and accurately. The extra points only
count if you have first achieved the 100%, whether than 100% comes
from the first six questions or from the last three.
Page 480
1) (10 points) Q. 2.
2) (10 points) Q. 3.
 I am changing this so that the filter takes the output of
ps auxw | awk ‘{print $11}’
This gives the command name for each process, most of
which will be in full path format.
 This filter will take this input and put out a new list of just
the command name, without the preceding path, using the
basename command to do this.
 Remember that a filter is a program/utility that takes
input from standard in and/or puts output to standard out.
Therefore, you will write a script that does what is asked.
3) (10 points) Q. 6.
 We talked about this in class. There is a command that you
can use to find out the type of any file given.
4) (10 points) Q. 7.
 Read the man page on sleep, clear, and date. This loop
could either keep looping forever, until you kill it using Ctrl-
1
C, the kill command, or close your terminal, or you could
give it a maximum number of loops. That’s your choice.
5) (10 points) Q. 13.
 Remember there is a way to set the field separator for bash.
6) (10 points) Q. 14.
Extra Credit: Worth another 100% (total of 120/60 points, or 200% for
this homework)
7) (20 points) Q. 11.
 Enhanced hint: use either the cut or the awk utility to get
something that you can compare.
 Change it so that if both have the same permissions, print
out, on one line, the permissions followed by the two
filenames. And if they have different permissions, print out
one line with the first file’s permissions followed by the
filename, and then a second line with the second line’s
permissions followed by the filename.
8) (20 points) Q. 17.
 The lnks script shown on p. 406 is long, extending through
two thirds of the next page. You can ignore the parts of the
script on p. 406, and at the top of p. 407. This is setup stuff,
and the only thing that you need to know is that $1 is the
one argument that was given on the command line when
running this script. The real logic starts at the comment
“Check that file exists and is an ordinary file”. There is a
command below this that only looks for one type of link.
9) (20 points) Q. 20.
 Note, this is asking for a function not a script.
 You need to output one thing, which is the length of the
filename which is the longest filename in the directory.
 Test first to make sure that the function’s argument is a
directory, and give an error if not.
2
Download