




















| |
Lab 12
(Chapter 12)
Learning Objectives
- To learn how to use UNIX
I/O redirection and pipe operators
- To learn to use the I/O
redirection and pipe operators to perform complex tasks which cannot be
performed by individual commands
- To learn how to use UNIX
FIFOs
- To learn how to use the
UNIX I/O operators, pipes, and FIFOs to perform challenging tasks which are
not possible with individual commands
Lab Work
- Log on to your UNIX system.
- Display
the absolute pathname for the foobar file in your home directory. Redirect
error messages to /dev/null. Show your session.
- Locate
the foobar file in your home directory and save its absolute pathname in the
foobar.path file. Append error messages to /dev/null. Show the contents of
foobar.path. Show your session.
- A
program, called banner, reads input from standard input and sends its output
to standard output. Run this program so that it reads input from the
student.records file and sends its output to the output.data file. Error
messages are appended to the error.log file. Show your session.
- Create a
file test.data using the cat
command that contains the following data. Once you have created the file,
display its content with the
cat command. Show your session.
This data is
to be stored in a file called test.data by using the cat command. We can create
the test.data file with this data by using a text editor such as vi. However,
the purpose of this exercise is to show an interesting use of output
redirection.
- Combine
data in the following files (in this order) and append it to the all.labs
file. Any errors should be redirected to the error.log file. Show your
session.
- The
smallFile file used in Lab 10 contains student records. Use a command line to
display the records for the top five students in ascending (sorted) order,
i.e., with the highest GPA student’s record displayed first. Show your
session.
- Perform
the task outlined in 7 and e-mail output of the command to yourself. Use one
command line. Show your session.
- Perform
the task outlined in 7 but print the output on the HP2_left printer with the
output page containing a nice header. Show your session.
- Use a
command line to perform the task outlined in 8 as well as save command output
in a file called topFiveList. Show your session.
- Create
two FIFOs, called fifo1 and fifo2. Use these FIFOs, the
tee command, and I/O
redirection operators to generate the following output: total number of
processes running on the system, status of all daemon processes, and total
number of daemons running on the system. Show your work.
- How many soft links are
there in the /usr directory. Show the command and its output.
- Logout
|