Subject: Assignment 3
Chapter 7 page 251 Exercises 1,3,4,8
1. What does the shell ordinarily do while a command is executing? What should you do if you do not want for a command to finish before running another command?
While the command is executing, the shell waits for the process to finish. Or sleeps
3. What is a PID number? Why are these numbers useful when you run processes in the background? Which utility displays the PID numbers of the commands you are running?
PID process identification numbers. Each of these numbers identifies the command running in the background. You can use the PS (process status) utility to display the PID numbers of running commands.
4. Assume that the following files are in the working directory:$ 1sintro notesb ref2 sectionl section3 section4bnotesa refl ref3 section2 section4a sentrev. Give commands for each of the following, using wildcards to express filenames with as few characters as possible. a. List all files that begin with section.
$ ls section*
b. List the section1, section2, and section3 files only.
$ ls section[1-3]
c. List the intro file only.
$ ls i*
d. List the section1, section3, ref1, and ref3 files.
$ ls *[13]
8. Give an example of a command that uses grep
a. With both input and output redirected.
$ grep \$Id < *.c > id_list
B. With only input redirected.
$ grep -i suzi < addresses
C. With only output redirected.
$ grep -il memo *.txt > memoranda_files
D. Within a pipe.
$ file /usr/bin/* | grep "Again shell script" | sort -r
In which of the preceding cases is grep used as a filter?
Part d uses grep as a filter.
Chapter 9 p.356, exercises 1,2,3,4,5,6,8
1. Explain the following unexpected result:
1. $ whereis date date: /bin/date ...
2. $ echo $PATH
.:/usr/local/bin:/usr/bin:/bin
3.$ cat > date echo "This is my own version of date."
4.$ ./date
Sat May 21 11:45:45 PDT 2011
1. "whereis date" tells us where the executable file "date" is