Installation guide
108 Chapter 11. Shell Prompt Basics
Sometimes, you may accidentally open a program file or some other non-text file in a terminal window.
Once you close the file, you could find that the text you are typing does not match the output on the
monitor.
In such cases, type reset to return the terminal window to its default values.
11.9. Manipulating Files with cat
Red Hat Linux has a utility which can help you keep short lists, gather those lists together, and (at the
same time) show you a little of the power behind your system.
The utility is called cat, short for concatenate, which means that it strings files together.
The command cat will also display the contents of an entire file on the screen (for example, type cat
filename.txt. If the file is fairly long, it will quickly scroll past you on the screen. To prevent this,
use the cat filename.txt | less command.
Using the pipe (|) and the less command displays the file one page at a time. You can then use the
left and right arrow keys to move back and forth through the pages. For more on pipes, see Section
11.10.
11.9.1. Using Redirection
Redirection means causing the shell to change what it considers to be standard input or where the
standard output should be going.
To redirect standard output, use the
symbol. Placing after the cat command (or after any utility or
application that writes to standard output) will direct its output to the filename following the symbol.
For example, using cat by itself simply outputs whatever you input to the screen as if it were repeating
the line you just typed. The following example shows cat repeating every line that is entered:
[sam@halloween sam]$cat
buy some sneakers
buy some sneakers
then go to the coffee shop
then go to the coffee shop
then buy some coffee
then buy some coffee
To redirect cat output to a file, type the following at a shell prompt (pressing the [Enter] key takes
you to the next blank line):
[sam@halloween sam]$cat
sneakers.txt
buy some sneakers
then go to the coffee shop
then buy some coffee