SLE201v15 Lab Exercise 3.3
SLE201v15 Lab Exercise 3.3
Description:
y
In this exercise, you redirect the output of commands into files and pipe the output of
nl
commands to other commands.
O
e
Task 1: Open a terminal session
te Us
1. On server2, as the tux user, open a terminal by clicking on the Activities menu and
type:
terminal
bu r
tri ne
When the Terminal icon appears, click on it to start a terminal session
Task 2: Use Redirection to Create a File
is rt
D Pa
1. Redirect the output of a command to a file on disk with:
ls /etc > dir-listing.txt
ot d
wc -l dir-listing.txt
Note the number of lines indicated for later reference.
D al
ls ~ > dir-listing.txt
o
wc -l dir-listing.txt
SE
Compare this number of lines with the previous steps number, indicating the file was
overwritten by the contents of your home directory.
SU
31
SUSE Linux Enterprise Administration
Task 5: Copy and Count the Lines in a File
1. Copy a sample text file from the documentation directories with:
cp /usr/share/doc/packages/vim/README.txt vim-readme.txt
2. Count the number of lines in the resulting file with:
wc -l vim-readme.txt
The file should contain 133 lines of content.
y
nl
Task 6: Number the Lines in a File
O
1. Number just the lines of a file that have content with:
nl vim-readme.txt
e
You will see the output indicates that 88 lines were numbered, leaving blank lines
te Us
unnumbered.
2. Number all lines of a file with:
bu r
nl -ba vim-readme.txt
tri ne
You will see the output indicates that all 133 lines were numbered, including lines with
no content.
is rt
D Pa
Task 7: Prepare a File for Printing
1. Keeping in mind the original number of lines in the file, add page numbers, line widths
and double-spacing to the file with:
ot d
N an
pr -d vim-readme.txt | wc -l
You will observe that the file is considerably lengthened by the formatting added to it by
the command.
D al
1. Prepare a raw text file on disk for printing and display the identical output on the console
te
with:
o
In
G
Note the number of lines in the output, for comparison in the next step.
SU
32
SUSE Linux Enterprise Administration
Summary:
In this exercise, you redirected the output of a command.
y
(End of Exercise)
nl
O
e
te Us
bu r
tri ne
is rt
D Pa
ot d
N an
D al
rn
te
o
In
SE
SU
33