O'Reilly logo

Unix Power Tools, 3rd Edition by Mike Loukides, Tim O'Reilly, Shelley Powers, Jerry Peek

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required