cat - Concatenate and print files
Synopsis
cat [-bcensStuv] [-] [file ...]
Description
The cat utility reads the specified
files sequentially, writing them to standard output. The file
operands are processed in command line order. A single dash
represents standard input.
By default, cat reads file as text
data so the data is translated from the CCSID of the file. When the
-c option is specified, cat reads
the file as binary data.
Note that because of the shell language mechanism used to
perform output redirection, the command cat
file1 file2 > file2 will cause the original data in file2
to be destroyed. Also, the process will go into an infinite
loop.
Options
- -b
- Number the output lines but do not number blank lines.
- -c
- Do not convert the data as it is read.
- -e
- Number the output lines and display a dollar sign ($) at the
end of each line as well.
- -n
- Number the output lines, starting at 1.
- -s
- Squeeze multiple adjacent empty lines, causing the output to be
single spaced.
- -S
- Squeeze multiple adjacent empty lines, causing the output to be
single spaced.
- -t
- Display non-printing characters so they are visible like the
-v option and display tab characters as well.
- -u
- Guarantee that the output is unbuffered.
- -v
- Display non-printing characters so they are visible. A control
character prints as "^X" (for control). The delete character prints
as "^?". A non-display character prints as "M-x" (for meta). Note
that in most locales, all of the characters are displayable.
Exit Status
- 0 when successful.
- >0 when an error occurred.
Related information
Examples
- Display the contents of file, "myfile".
cat myfile
- Display the contents of three different files at the same time
and save their contents into a new file.
cat file1 file2 file3 > all.files