The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

cat - concatenate and print files

 SYNOPSIS



cat [-u][file ...]

 DESCRIPTION

The cat utility reads files in sequence and writes their contents to the standard output in the same sequence.

 OPTIONS

The cat utility supports the XBD specification, Utility Syntax Guidelines  .

The following option is supported:

-u
Write bytes from the input file to the standard output without delay as each is read.

 OPERANDS

The following operand is supported:
file
A pathname of an input file. If no file operands are specified, the standard input is used. If a file is "-", the cat utility will read from the standard input at that point in the sequence. The cat utility will not close and reopen standard input when it is referenced in this way, but will accept multiple occurrences of "-" as a file operand.

 STDIN

The standard input is used only if no file operands are specified, or if a file operand is "-". See the INPUT FILES section.

 INPUT FILES

The input files can be any file type.

 ENVIRONMENT VARIABLES

The following environment variables affect the execution of cat:
LANG
Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
LC_ALL
If set to a non-empty string value, override the values of all the other internationalisation variables.
LC_CTYPE
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments).
LC_MESSAGES
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
NLSPATH
Determine the location of message catalogues for the processing of LC_MESSAGES .

 ASYNCHRONOUS EVENTS

Default.

 STDOUT

The standard output will contain the sequence of bytes read from the input files. Nothing else will be written to the standard output.

 STDERR

Used only for diagnostic messages.

 OUTPUT FILES

None.

 EXTENDED DESCRIPTION

None.

 EXIT STATUS

The following exit values are returned:
0
All input files were output successfully.
>0
An error occurred.

 CONSEQUENCES OF ERRORS

Default.

 APPLICATION USAGE

The -u option has value in prototyping non-blocking reads from FIFOs. The intent is to support the following sequence:

mkfifo foo
cat -u foo > /dev/tty13 &
cat -u > foo

It is unspecified whether standard output is or is not buffered in the default case. This is sometimes of interest when standard output is associated with a terminal, since buffering may delay the output. The presence of the -u option guarantees that unbuffered I/O is available. It is implementation-dependent whether the cat utility buffers output if the -u option is not specified. Traditionally, the -u option is implemented using the equivalent of the XSH specification setvbuf() function.

 EXAMPLES

The following command:

cat myfile

writes the contents of the file myfile to standard output.

The following command:


cat doc1 doc2 > doc.all

concatenates the files doc1 and doc2 and writes the result to doc.all.

Because of the shell language mechanism used to perform output redirection, a command such as this:


cat doc doc.end > doc

causes the original data in doc to be lost.

The command:


cat start - middle - end > file

when standard input is a terminal, gets two arbitrary pieces of input from the terminal with a single invocation of cat. Note, however, that if standard input is a regular file, this would be equivalent to the command:

cat start - middle /dev/null end > file

because the entire contents of the file would be consumed by cat the first time "-" was used as a file operand and an end-of-file condition would be detected immediately when "-" was referenced the second time.

 FUTURE DIRECTIONS

None.

 SEE ALSO

more.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]