NAME
cat - Concatenates or displays files
SYNOPSIS
cat [-benrstuv] file ... | -
The cat command reads each specified file in sequence and
writes it to standard output.
FLAGS
-b Omits line numbers from blank lines when -n is speci-
fied.
-e Same as the -v flag with a $ (dollar sign) character
displayed at the end of each line.
-n Displays output lines preceded by line numbers, numbered
sequentially from 1.
-r Replaces multiple consecutive empty lines with one empty
line, so that there is never more than one empty line
between lines containing characters.
-s Does not display a message if cat cannot find an input
file. (Silent option.)
-t Same as the -v flag, with the tab character printed as
<Ctrl-i> (^I).
-u Does not buffer output.
-v Displays nonprinting characters so that they are visi-
ble.
DESCRIPTION
The cat command is frequently used with > (redirection sym-
bol) to concatenate the specified files and write them to
the specified destination. (See CAUTIONS.) cat is also
used with >> to append a file to another file.
If you do not specify a file or if you specify - (dash)
instead of file, cat reads from standard input.
EXAMPLES
1. To display the file notes, enter:
cat notes
If the file is longer than one screenful, it scrolls by
too quickly to read. To display a file one page at a
time, use the more command.
2. To concatenate several files, enter:
cat section1.1 section1.2 section1.3 > section1
This creates a file named section1 that is a copy of
section1.1 followed by section1.2 and section1.3.
3. To suppress error messages about files that do not
exist, enter:
cat -s section2.1 section2.2 section2.3 > section2
If section2.1 does not exist, this command concatenates
section2.2 and section2.3. Note that the message goes
to standard error, so it does not appear in the output
file. The result is the same if you do not use the -s
flag, except that cat displays the error message:
cat: cannot open section2.1
You may want to suppress this message with the -s flag
when you use the cat command in shell procedures.
4. To append one file to the end of another, enter:
cat section1.4 >> section1
The >> in this command specifies that a copy of sec-
tion1.4 be added to the end of section1. If you want
to replace the file, use a single > symbol.
5. To add text to the end of a file, enter:
cat >> notes
Get milk on the way home
<Ctrl-d>
Get milk on the way home is added to the end of notes.
With this syntax, the cat command does not display a
prompt; it waits for you to enter text. Press the
End-of-File key sequence (<Ctrl-d> above) to indicate
you are finished.
6. To concatenate several files with text entered from the
keyboard, enter:
cat section3.1 - section3.3 > section3
This concatenates section3.1, text from the keyboard,
and section3.3 to create the file section3.
7. To concatenate several files with output from another
command, enter:
ls | cat section4.1 - > section4
This copies section4.1, and then the output of the ls
command to the file section4.
CAUTIONS
Do not redirect output to one of the input files using the >
(redirection symbol). If you do this, you lose the original
data in the input file because the shell truncates it before
cat can read it. (See also the sh command.)
RELATED INFORMATION
Commands: cp(1), dd(1), more(1), pack(1)/pcat(1)/unpack(1),
pg(1), pr(1), sh(1).
Acknowledgement and Disclaimer