*** Welcome to piglix ***

Cat (Unix)


cat is a standard Unix utility that reads files sequentially, writing them to standard output. The name is derived from its function to concatenate files.

Cat was part of the early versions of Unix, e.g., Version 1, and replaced pr, a PDP-7 utility for copying a single file to the screen.

The Single Unix Specification defines the operation of cat to read files in the sequence given in its arguments, writing their contents to the standard output in the same sequence. The specification mandates the support of one option flag, u for unbuffered output, meaning that each byte is written after it has been read. Some operating systems, like the ones using GNU Coreutils, do this by default and ignore the flag.

If one of the input filenames is specified as a single hyphen (-), then cat reads from standard input at that point in the sequence. If no files are specified, cat reads from standard input only.

The command-syntax is:

The output of cat may be redirected to a file:

or it may be redirected as input to another program, e.g.:

which invokes the less paging utility.

The OpenBSD manual page and the GNU coreutils version of cat specify the following options:

cat can be used to pipe a file to a program that expects plain text or binary data on its input stream. cat does not destroy non-text bytes when concatenating and outputting. As such, its two main use cases are text files and certain format-compatible types of binary files.

Concatenation of text is limited to text files using the same legacy encoding, such as ASCII. cat does not provide a way to concatenate Unicode text files that have a Byte Order Mark or files using different text encodings from each other.

For many structured binary data sets, the resulting combined file may not be valid; for example, if a file has a unique header or footer, the result will spuriously duplicate these. However, for some multimedia digital container formats, the resulting file is valid, and so cat provides an effective means of appending files. Video streams can be a significant example of files that cat can concatenate without issue, e.g. the MPEG program stream (MPEG-1 and MPEG-2) and DV (Digital Video) formats, which are fundamentally simple streams of packets.


...
Wikipedia

...