cat - concatenate and print files
cat [-u][file ...]
The cat utility reads files in sequence and writes their contents to the standard output in the same sequence.
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.
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.
The standard input is used only if no file operands are specified, or if a file operand is "-". See the INPUT FILES section.
The input files can be any file type.
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 .
Default.
The standard output will contain the sequence of bytes read from the input files. Nothing else will be written to the standard output.
Used only for diagnostic messages.
None.
None.
The following exit values are returned:
- 0
- All input files were output successfully.
- >0
- An error occurred.
Default.
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.
The following command:writes the contents of the file myfile to standard output.cat myfile
The following command:
concatenates the files doc1 and doc2 and writes the result to doc.all.cat doc1 doc2 > doc.all
Because of the shell language mechanism used to perform output redirection, a command such as this:
causes the original data in doc to be lost.cat doc doc.end > doc
The command:
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 - 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.cat start - middle /dev/null end > file
None.
more.