cat(1) cat(1)
NAME
cat - concatenate and print files
SYNOPSIS
cat [-s] [-u] [-v[et]] [--] [file ...]
DESCRIPTION
The cat command reads files in sequence and writes them to standard
output. cat has no effect on the sequence and format of the characters
in the files.
If you name more than one file when calling cat, these files are out-
put sequentially in the specified order.
If you do not name a file, cat reads from standard input.
OPTIONS
No option specified:
Output is buffered in BUFSIZ-byte blocks. The value of BUFSIZ is
governed by the machine you are working on. It is defined in the
file /usr/include/stdio.h and may be 512, 1024, 4096 or 8192
bytes. If the files named on the command line do not exist, cat
tells you that it cannot open them.
-s Messages reporting that files do not exist are suppressed.
-u Output without buffering, one byte at a time.
-v Non-printing characters (with the exception of tabs, newlines and
form feeds) are written to standard output in the following form:
- Control characters: ^x (CTRL-x)
The possible values for x in the ISO 646 character set are
shown in the table in ascii(5).
- DEL (octal 177): ^?
- Non-ASCII characters (with the high bit set): M-x, where x is
the character defined by the 7 remaining bits.
-e Only works together with the -v option.
A dollar character $ appears at the end of each line (prior to
the newline character).
-t Only works together with the -v option.
Tabs appear as: ^I, form feeds appear as: ^L
-- If file begins with a dash (-), the end of the command-line
options must be marked with --.
Page 1 Reliant UNIX 5.44 Printed 11/98
cat(1) cat(1)
file Name of the file that is to be printed. You may specify more than
one file. If you use a dash as the name for file, cat reads from
standard input.
file not specified:
cat reads from standard input.
Caution:
Redirecting the output of cat to one of the files being read will
result in the loss of that file's original contents. In the fol-
lowing command, for example, the contents of file1 are lost:
cat file1 file2 file3 > file1
ERROR MESSAGES
cat >outfile
outfile: cannot create
You do not have write permission for the output file outfile or
for the directory containing outfile.
cat infile
cat: cannot open infile
You do not have read permission for the input file infile.
LOCALE
The LCMESSAGES environment variable governs the language in which
message texts are displayed.
LCCTYPE governs character classes, character conversion (shifting)
and the behavior of character classes in regular expressions.
If LCMESSAGES or LCCTYPE is undefined or is defined as the null
string, it defaults to the value of LANG. If LANG is likewise unde-
fined or null, the system acts as if it were not internationalized.
If any of the locale variables has an invalid value, the system acts
as if none of the variables were set.
Page 2 Reliant UNIX 5.44 Printed 11/98
cat(1) cat(1)
EXAMPLES
Example 1
Concatenate and redirect the output of two files:
$ echo Monday Tuesday Wednesday >file1
$ echo Thursday Friday Saturday >file2
$ cat file1 file2 > file3
$ cat file3
Monday Tuesday Wednesday
Thursday Friday Saturday
Example 2
Display the contents of file1
$ cat file1
In Xanadu did Kubla Khan
A stately pleasure dome decree:
Where Alph, the sacred river, ran
Now write two lines of text into file2
$ cat > file2
Through caverns measureless to man
Down to a sunless sea.
<CTRL-D>
Now move the contents of file1 and file2 to file3, add two lines from
standard input, and then print the contents of file3.
$ cat file1 file2 - > file3
For he on honey dew hath fed
And drunk the milk of paradise.
<CTRL-D>
$ cat file3
In Xanadu did Kubla Khan
A stately pleasure dome decree:
Where Alph, the sacred river, ran
Through caverns measureless to man
Down to a sunless sea.
For he on honey dew hath fed
And drunk the milk of paradise.
SEE ALSO
cp(1), pg(1), pr(1), ascii(5).
Page 3 Reliant UNIX 5.44 Printed 11/98