Main Page | See live article | Alphabetical index

Cat (Unix)

In Unix and Unix-like operating systems, the cat program concatenates the contents of files, reading from a list of files and/or standard input in sequence and writing their contents in order to standard output. cat takes the list of files as arguments but also interprets the argument '-' as standard input.

Jargon File definition

The Jargon File version 4.3.3 lists this as the definition of cat:

1. [techspeak] To spew an entire file to the screen or some other output sink without pause (syn. blast). 2. By extension, to dump large amounts of data at an unprepared target or with no intention of browsing it carefully. Usage: considered silly. Rare outside Unix sites. See also dd, BLT.

Among Unix fans, cat(1) is considered an excellent example of user-interface design, because it delivers the file contents without such verbosity as spacing or headers between the files, and because it does not require the files to consist of lines of text, but works with any sort of data.

Among Unix haters, cat(1) is considered the canonical example of bad user-interface design, because of its woefully unobvious name. It is far more often used to blast a file to standard output than to concatenate two files. The name cat for the former operation is just as unintuitive as, say, LISP's cdr.

UUOC [from the comp.unix.shell group on Usenet] stands for `Useless Use of cat'; the reference is to the Unix command cat(1), not the feline animal. As received wisdom on comp.unix.shell observes, "The purpose of cat is to concatenate (or `catenate') files. If it's only one file, concatenating it with nothing at all is a waste of time, and costs you a process." Nevertheless one sees people doing

    cat file | some_command and its args ...

instead of the equivalent and cheaper

    
or (equivalently and more classically)

    some_command and its args ... 
Since 1995, occasional awards for UUOC have been given out, usually by Perl luminary Randal L. Schwartz. There is a web page devoted to this and other similar awards. In British hackerdom the activity of fixing instances of UUOC is sometimes called demoggification.

External link