Installation guide
Chapter 11. Shell Prompt Basics 111
Figure 11-7. Stringing Commands and Comparing Files
11.9.3. Redirecting Standard Input
Not only can you redirect standard output, you can perform the same type of redirection with standard
input.
When you use the redirect standard input symbol
, you are telling the shell that you want a file to be
read as input for a command.
Use a file you have already created to demonstrate this idea. Just type:
cat
sneakers.txt
Because you used the less-than symbol ( ) to separate the cat command from the file, the output of
sneakers.txt was read by cat.
11.10. Pipes and Pagers
In Linux, pipes connect the standard output of one command to the standard input of another com-
mand.
Consider the ls command that was discussed earlier. There are plenty of options available with ls,
but what if the contents of a directory scroll by too quickly for you to view them?
View the contents of the /etc directory.
ls -al /etc
How do you get a closer look at the output before it moves off the screen?
One way is to pipe the output to a utility called less. Known as a pager, less allows you to view
information one page (or screen) at a time.
Use the vertical bar (|) to pipe the commands.
ls -al /etc | less
Now we can view the contents of one /etc screen at a time. To move forward a screen, press [Space];
to move back a screen, press [b]; to quit, press [q]. You can use the [left] and [right] arrow keys to
navigate as well.