Cat (Unix)
Cat (Unix)
Main page
623490

Cat (Unix)

logo
Community Hub0 subscribers
What are your thoughts?
Be the first to start a discussion here.
Be the first to start a discussion here.
Cat (Unix)

cat is a shell command for writing the content of a file or input stream to standard output. The name is an abbreviation of catenate, a variant form of concatenate. Originally developed for Unix, it is available on many operating systems and shells today.

In addition to combining files, cat is commonly used to copy files and in particular to copy a file to the terminal monitor. Unless redirected, cat outputs file content on-screen.

cat was part of the early versions of Unix, e.g., Version 1. It replaced pr, a PDP-7 and Multics command for copying a single file to the screen. It was written by Ken Thompson and Dennis Ritchie. The implementation of cat bundled in GNU coreutils was written by Torbjorn Granlund and Richard Stallman.

The cat command can be used to serve various needs including concatenation and display. A use case for concatenation is to specify multiple input files and to redirect output to another file to persist the result. A common use case for display is to specify a single file without redirecting output so that the file content displays on the monitor.

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 implementations, like GNU Core Utilities, 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:

Options include:

See all
User Avatar
No comments yet.