Exercises
What does the shell ordinarily do while a command is executing? What should you do if you do not want to wait for a command to finish before running another command?
Using sort as a filter, rewrite the following sequence of commands:
$ sort list > temp $ lpr temp $ rm temp
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?
Assume the following files are in the working directory:
$ ls intro notesb ref2 section1 section3 section4b notesa ref1 ref3 section2 section4a sentrev
Give commands for each of the following, using wildcards to express filenames with as few characters as possible.
List all files that begin with section.
List the section1, section2, and section3 files only.
List the intro file only.
List the section1, section3, ref1, and ref3 files.
Refer to Part VII or the info or man pages to determine which command will
Display the number of lines in its standard input that contain the word a or A.
Display only the names of the files in the working directory that contain the pattern $(.
List the files in the working directory in reverse alphabetical order.
Send a list of files in the working directory to the printer, sorted by size.
Give a command to
Redirect standard output from a sort command to a file named phone_list. Assume the input file is named numbers.
Translate all occurrences of the characters [ and { to the character (, and all occurrences of the characters ] and } to the character ), in the file permdemos.c. (Hint: Refer to tr on page 1014.)
Create a file named book that contains the contents of two other files: part1 and part2.
The lpr and sort utilities accept input either from a file named on the command line or from standard input.
Name two other utilities that function in a similar manner.
Name a utility that accepts its input only from standard input.
Give an example of a command that uses grep
With both input and output redirected.
With only input redirected.
With only output redirected.
Within a pipeline.
In which of the preceding cases is grep used as a filter?
Explain the following error message. Which filenames would a subsequent ls command display?
$ ls abc abd abe abf abg abh $rm abc ab* rm: cannot remove 'abc': No such file or directory