CAT(1) General Commands Manual CAT(1)

catconcatenate files

cat [-us] [-n|-b] [-TEv] [-teA] [file]…

Copies each file (standard input stream if "-", the default), in order, to the standard output stream. In case of an input error, the file is skipped but processing continues.

Don't buffer output. Input is never buffered.
, --squeeze-blank
Replace runs of empty input lines with a single one.

, --number
Number lines from 1, separating them from the file contents with a tab.
, --number-nonblank
Likewise, but don't number empty lines.

, --show-tabs
Replace tab characters with "^I".
, --show-ends
Prepend newlines with a dollar ("$").
, --show-nonprinting
Replace non-printable bytes ([, ] ∪ [, ] - { (tab), (newline)}) with their corresponding "^c" and "M-c" escapes (see STANDARDS, Escapes).
, --show-all

1 if a file couldn't be opened or read.

$ echo echoed | cat
echoed

$ echo abcdefg | split -b3
$ printf : | cat xaa - xab - xac
abc:defg
$ cat xaa - xab - xac  # teletype input bolded
abcA
A
^DdefB
B
^Dg

$ cat form
Groceries for February:


        Bananas 3.5kg   $4.51
        Kiwis   2kg     $3.19   Call Siegfried to explain short!
        Bread           $20.21
$ cat -sbte form
     1  Groceries for February:$
$
     2  ^IBananas^I3.5kg^I$4.51$
     3  ^IKiwis^I2kg^I$3.19^ICall Siegfried to explain short!$
     4  ^IBread^I^I$20.21$

cp(1), dd(1), head(1), pr(1), tail(1), ascii(7)

Conforms to IEEE Std 1003.1-2008 (“POSIX.1”); -u is the only flag specified by the standard. -nb, -s, -tev compatible with 4BSD. Remaining flags (-TEA) compatible with the GNU system.

0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF
0x00 ^@ ^A ^B ^C ^D ^E ^F ^G ^H ^I ^K ^L ^M ^N ^O
0x10 ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^\ ^] ^^ ^_
0x70 ^?

Above , the table repeats but with M- prepended (i.e. is M-A and M-^J).

Appears in the first edition of the UNIX Programmer's Manual as cat(I):

With the standard input stream used if no files, as present-day.

Version 3 AT&T UNIX adds the "-"-as-standard-input-stream behaviour. This can safely be considered fully-formed.

Version 7 AT&T UNIX sees a rewrite in C with <stdio.h>, and -u disabling buffering of the standard output stream (considering it feeds getc() directly into putchar() until end-of-file, this is a significant penalty, but is, regardless, most likely decidedly slower than the previous implementation, which mapped full-block read(II)s onto write(II)s). It also explicitly checks for, skips, and warns about one of the input files also being bound to the standard output stream.

3BSD uses a larger, -byte BUFSIZ, and hence output buffer.

4BSD introduces -nb, -s, and -tve — all as today.

4.3BSD sees a fast read(2)/write(2) path if no flags were specified.

Programmer's Workbench (PWB/UNIX), instead, sees -s, silencing errors, and a re-write in terms of read(2)/write(2). Oddly, AT&T System III UNIX inherits this -s into an Version 7 AT&T UNIX base.

AT&T System V Release 2 UNIX also sees -tve, except -te require -v to activate, -t also controls (form feed), and M-^J (newline + high bit) is M-$<newline>. The former can be attributed to implementing according to the 4BSD manpage, which erroneously implies the -v requirement. The latter only to low QoI. Without -v, a block-wise read(2)/write(2) copy is performed.

June 9, 2023 voreutils pre-v0.0.0-latest