O'Reilly logo

Linux Pocket Guide, 2nd Edition by Daniel J. Barrett

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

Name

cat — stdin  stdout  - file  -- opt  --help  --version

Synopsis

cat [options] [files]

The simplest viewer is cat, which just prints its files to standard output, concatenating them (hence the name). Large files will likely scroll off screen, so consider using less if you plan to read the output. That being said, cat is particularly useful for sending a set of files into a shell pipeline:

$ cat * | wc

cat can also manipulate its output in small ways, optionally displaying nonprinting characters, prepending line numbers (though nl is more powerful for this purpose), and eliminating whitespace.

Useful options

-T

Print tabs as ^I.

-E

Print newlines as $.

-v

Print other nonprinting characters in a human-readable format.

-n

Prepend line numbers to every line.

-b

Prepend line numbers to nonblank lines.

-s

Squeeze each sequence of blank lines into a single blank line.

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