From Wikipedia, the free encyclopedia cat (Unix)
cat (Unix)
The cat command is a standard Unix program used to quire the files to consist of lines of text, but works
concatenate and display files. The name is from catenate, with any sort of data.
a synonym of concatenate. Among Unix critics, cat(1) is considered the
canonical example of bad user-interface design, be-
Specification cause of its woefully unobvious name. It is far more of-
ten used to blast a single file to standard output than
The Single Unix Specification specifies the behavior that to concatenate two or more files. The name cat for
the contents of each of the files given in sequence as ar- the former operation is just as unintuitive as, say,
guments will be written to the standard output in the LISP’s cdr.
same sequence, and mandates one option, -u, where
each byte is printed as it is read.
If the filename is specified as -, then cat will read Useless use of cat
from standard input at that point in the sequence. If no UUOC (from comp.unix.shell on Usenet) stands for "Use-
files are specified, cat will read from standard input en- less Use of cat". As received wisdom on comp.unix.shell ob-
tered. serves "The purpose of cat is to concatenate (or ’cate-
nate’) files. If it’s only one file, concatenating it with
Extensions nothing at all is a waste of time, and costs you a process."
Both the BSD versions of cat (as per the OpenBSD man- This is also referred to as "Cat abuse". Nevertheless one
page) and the GNU coreutils version of cat specify the sees people doing
following options:
cat filename | cmd arg1 arg2 argn
• -b (GNU only: --number-nonblank), number
non-blank output lines
instead of the (not quite) equivalent and cheaper
• -n (GNU only: --number), number all output lines
• -s (GNU only: --squeeze-blank), squeeze " instead of "" will truncate the file.
file is valid, and this provides a very simple way of con- [3] http://partmaps.org/era/unix/award.html
catenating files, particularly video streams. Significantly, [4] moggy is chiefly British word for "(mongrel) cat",
the MPEG program stream (MPEG-1 and MPEG-2) and DV hence demoggification literally means "removal of
(Digital Video) formats can be so concatenated – such a (non-special) cats".
stream is fundamentally a stream of packets, which can [5] FFmpeg FAQ: 3.15 How can I join video files?
thus be joined.
Further, any other video format can be concatenated
by transcoding to one of these privileged formats, con-
External links
catenating via cat, and then transcoding back. This pro- • cat: concatenate and print files – Commands &
cedure is in fact endorsed by FFmpeg.[5] Utilities Reference, The Single UNIX® Specification,
Issue 7 from The Open Group
• UNIX Style, or cat -v Considered Harmful - A paper
Other operating systems by Rob Pike on proper Unix command design using
The equivalent command in the VMS, CP/M, DOS, OS/2, cat as an example.
and Microsoft Windows operating system command
shells is type. Manual pages
Note: To combine multiple files together in DOS/Win- • cat(1) original manual page in the First Edition of
dows you can use the "copy /b" command: Unix.
Example: • cat(1): concatenate and write files – GNU
Coreutils reference
copy /b file1.txt + file2.txt file3.txt
• cat(1): concatenate and print files – OpenBSD
General Commands Manual
This copies file1.txt and file2.txt in binary mode together
• cat(1) – FreeBSD General Commands Manual
in one file, file3.txt.
• cat(1): catenate files – Plan 9 from Bell Labs
manual
See also
• List of Unix utilities Other
• split, a command that splits a file into pieces • Useless Use Of Cat Award
which cat can then rejoin.
Retrieved from "http://en.wikipedia.org/w/index.php?title=Cat_(Unix)&oldid=467646005"
Categories:
• Unix text processing utilities
• Standard Unix programs
• Unix SUS2008 utilities
This page was last modified on 25 December 2011 at 17:24. Text is available under the Creative Commons Attribution-
ShareAlike License; additional terms may apply. See Terms of use for details. Wikipedia® is a registered trademark of
the Wikimedia Foundation, Inc., a non-profit organization.Contact us
Privacy policy About Wikipedia Disclaimers
2