Chapter 12. Showing What’s in a File

Cracking the Nut

What Good Is a cat?

The cat command may well be the first command new users hear about, if only because of its odd name. cat stands for concatenate 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 takes its input and spits it out again.

cat has many uses, but the four most basic applications are described in the following list. In many ways, they don’t illustrate cat so much as they illustrate the shell’s output redirection (Section 43.1) mechanism.

  1. First form:

    % cat 
                         file
    % cat 
                         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 a pager such as less (Section 12.3).[1]

  2. Second form: ...

Get Unix Power Tools, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.