Showing What's in a File
command may well be the first command new users
hear about, if only because of its odd name.
stands for concat
enate or, as some would say,
catenate. Both words mean the same thing: to connect
in a series. The cat
command takes its filename arguments,
and strings their contents together. Essentially, cat
its input and spits it out again.
has many uses, but the four most basic applications are
described in the following list.
In many ways, they don't illustrate cat
much as they illustrate the shell's
output redirection (13.1
file1 file2 file...
Use this form to display one or more files on the screen.
The output doesn't pause when the screen is full. As a result,
if your files are more than one screenful long, the output
will whiz by without giving you a chance to read it. To read
output by screenfuls, use the
command or some other pager, like
Use this form when you want to combine several smaller files into
one large file. Be sure the destination file does not already exist;
otherwise, it will be replaced by the new contents (effectively destroying the
original). For example, the command:
cat chap1 chap2 chap3 > book
creates a new file, book
, composed of three files,
one after the other. The three component files still exist
, and chap3
Use this form to add one or more files to the end of an existing
file. For example:
cat note1 note2 > note_list
cat note3 >> note_list
Use this form as a quick-and-dirty way to create a new file.
This is useful when you aren't yet familiar with any of the
standard text editors. With this command, everything
you type at the keyboard goes into the new file.
(You won't be able to back up to a previous line.)
To finish your input, enter CTRL-d on a line by itself.
Well, that was just in case there are some beginners on board.
give some more useful tips about cat