Talk:Cat (Unix)

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

copy commands[edit]

Unix/*nix programs (Also sometimes used in Windows versions)
  • cp -- copy files; can concatenate files
  • cpio -- copy an entire directory structure from one place to another
  • cat -- concatenate and display files
  • dd -- copy streams, files, or devices in whole or part
  • head -- display/copy the first part of a file
  • tail -- display/copy the last part of a file


DOS/Windows programs (Seldom used in *nix versions)
  • COPY -- copy files or sets of files, binary or text mode, can concatenate files
  • XCOPY -- eXtended version of COPY, for copying file structures
  • XXCOPY -- further extended commercial program
  • ROBOCOPY -- further extended version, included in Vista


Other specialized programs are used to split large files into pieces and then put the pieces back together.

There are no good standard programs to extract an arbitrary piece of a file into another file. dd can be used, but requires setting blocksize to 1, which is very inefficient. In Windows, the obscure program CPART can be used.

grep and awk are powerful *nix programs for looking for patterns in a file.

00:30, 17 October 2007 (UTC)

Seeking[edit]

I think that most people likely to use Linux or UNIX by the terminal understand the implications of a command being able to seek in a file. This implies that the command is able to go back and forth through the file, and possibly read from it multiple times, which could allow optimization. — Preceding unsigned comment added by 107.77.164.39 (talk) 17:12, 17 June 2016 (UTC)[reply]

UTF-8 BOM handling[edit]

It is not clear if cat command can concatenates texts files starting with UTF-8 Byte order Mark (BOM). Does such an option exist? Or is cat not suitable for text file processing? — Preceding unsigned comment added by 86.75.236.140 (talk) 10:48, 30 June 2012 (UTC)[reply]

Removal of "tac" section[edit]

Hello! I'd suggest that the cat (Unix) § tac section is deleted, because it presents a rather unrelated utility and thus provides no encyclopedic value. Moreover, why would one alternative utility be favored over other similar alternative utilities? -- 31.223.130.158 (talk) 08:57, 24 November 2021 (UTC)[reply]

Since nobody objected in a week, I'll delete this section. -- 31.223.130.200 (talk) 18:25, 1 December 2021 (UTC)[reply]
As a note, I'm not a newbie around here, :) but an experienced Wikipedia editor with about 40k edits. I just decided not to login into my old account. -- 31.223.130.183 (talk) 09:41, 2 December 2021 (UTC)[reply]
Alright, I went ahead and briefly described the alternative utilities in general, in the cat (Unix) § History section. That should suffice, and won't make any of the available alternative utilities privileged. -- 31.223.130.183 (talk) 10:14, 2 December 2021 (UTC)[reply]

The Origin of the Name[edit]

Citation was requested for the name etymology.

In the V7 sources, the 'beginners' document has the following text (found in usr/doc/beginnner/u2, rendered with nroff -ms, and adjusted for this post)

   First  is  cat, the simplest of all the printing programs.  cat
   simply prints on the terminal the contents of all the files named
   in a list.  Thus
       cat junk
   prints one file, and
       cat junk temp
   prints two.  The files are simply concatenated  (hence  the  name
   ‘‘cat’’) onto the terminal.


tying the name 'cat' to the word 'concatenated' leading support to the 'second syllable' hypothesis.

All research edition PDP-11 sources of cat start with

  /*
   * Concatenate files.
   */

(or the assembler equivalent) which leads credence to it as well.

The manual in the 0th (pdp7) and 1st through 6th edition starts with some variation of the following in usr.doc/man/man1/cat.1 NAME cat -- concatenate and print But the 7th, 8th and 10th edition has in usr/doc/man/man1/cat.1 cat \- catenate and print to tie it more closely to the obscure word 'catenate' (see https://www.merriam-webster.com/dictionary/catenate for definition).

Pike opines in his design of unix paper: "Even the name cat is typical of UNIX program names: it is short, pronounceable, but not conventional English for the job it does." concatenate is the conventional name. catenate is a happy accident here. So more circumstantial evidence.

Finally, "concatenate and transmit" has been proposed an alternate hypothesis. However, apart from one facebook post, I can't find that phrase anywhere. It's nowhere in the TUHS unix archive. And the google search ("concatenate and transmit" unix) returns no matches. It's not in any of the bell/AT&T technical journals (which mention cat, but not its name).

Though with all of that, I couldn't find a direct source of any specific etymology. Bsdimp (talk) 17:39, 23 December 2023 (UTC)[reply]

Oh, it's there in Kernighan and Pike "The UNIX Programming Environment" 1984 p15:
"The named file or files are catenated† (hence the name "cat") onto the terminal one after another with nothing between."
"† "Catenate" is a slightly obscure synonym for "concatenate.""
Updated to include this reference. I'm unsure how to cite the V7 man page, so I didn't do that... Bsdimp (talk) 21:16, 23 December 2023 (UTC)[reply]