1CAT(1P)                    POSIX Programmer's Manual                   CAT(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       cat — concatenate and print files
14

SYNOPSIS

16       cat [−u] [file...]
17

DESCRIPTION

19       The cat utility shall read files in sequence and shall write their con‐
20       tents to the standard output in the same sequence.
21

OPTIONS

23       The  cat  utility  shall  conform  to  the  Base  Definitions volume of
24       POSIX.1‐2008, Section 12.2, Utility Syntax Guidelines.
25
26       The following option shall be supported:
27
28       −u        Write bytes from the input file to the standard output  with‐
29                 out delay as each is read.
30

OPERANDS

32       The following operand shall be supported:
33
34       file      A  pathname  of an input file. If no file operands are speci‐
35                 fied, the standard input shall be used. If a file is '−', the
36                 cat  utility shall read from the standard input at that point
37                 in the sequence. The cat utility shall not close  and  reopen
38                 standard  input  when it is referenced in this way, but shall
39                 accept multiple occurrences of '−' as a file operand.
40

STDIN

42       The standard input shall be used only if no file  operands  are  speci‐
43       fied, or if a file operand is '−'.  See the INPUT FILES section.
44

INPUT FILES

46       The input files can be any file type.
47

ENVIRONMENT VARIABLES

49       The following environment variables shall affect the execution of cat:
50
51       LANG      Provide  a  default  value for the internationalization vari‐
52                 ables that are unset or null. (See the Base Definitions  vol‐
53                 ume  of POSIX.1‐2008, Section 8.2, Internationalization Vari‐
54                 ables for the precedence  of  internationalization  variables
55                 used to determine the values of locale categories.)
56
57       LC_ALL    If  set  to  a non-empty string value, override the values of
58                 all the other internationalization variables.
59
60       LC_CTYPE  Determine the locale for the interpretation of  sequences  of
61                 bytes of text data as characters (for example, single-byte as
62                 opposed to multi-byte characters in arguments).
63
64       LC_MESSAGES
65                 Determine the locale that should be used to affect the format
66                 and  contents  of  diagnostic  messages  written  to standard
67                 error.
68
69       NLSPATH   Determine the location of message catalogs for the processing
70                 of LC_MESSAGES.
71

ASYNCHRONOUS EVENTS

73       Default.
74

STDOUT

76       The  standard  output shall contain the sequence of bytes read from the
77       input files. Nothing else shall be written to the standard output.
78

STDERR

80       The standard error shall be used only for diagnostic messages.
81

OUTPUT FILES

83       None.
84

EXTENDED DESCRIPTION

86       None.
87

EXIT STATUS

89       The following exit values shall be returned:
90
91        0    All input files were output successfully.
92
93       >0    An error occurred.
94

CONSEQUENCES OF ERRORS

96       Default.
97
98       The following sections are informative.
99

APPLICATION USAGE

101       The −u option has value in prototyping non-blocking reads  from  FIFOs.
102       The intent is to support the following sequence:
103
104           mkfifo foo
105           cat −u foo > /dev/tty13 &
106           cat −u > foo
107
108       It  is unspecified whether standard output is or is not buffered in the
109       default case. This is sometimes of interest  when  standard  output  is
110       associated  with  a terminal, since buffering may delay the output. The
111       presence of the −u option guarantees that unbuffered I/O is  available.
112       It  is implementation-defined whether the cat utility buffers output if
113       the −u option is not specified. Traditionally, the −u option is  imple‐
114       mented  using  the  equivalent of the setvbuf() function defined in the
115       System Interfaces volume of POSIX.1‐2008.
116

EXAMPLES

118       The following command:
119
120           cat myfile
121
122       writes the contents of the file myfile to standard output.
123
124       The following command:
125
126           cat doc1 doc2 > doc.all
127
128       concatenates the files doc1 and doc2 and writes the result to doc.all.
129
130       Because of the shell language mechanism used to  perform  output  redi‐
131       rection, a command such as this:
132
133           cat doc doc.end > doc
134
135       causes the original data in doc to be lost.
136
137       The command:
138
139           cat start − middle − end > file
140
141       when  standard  input is a terminal, gets two arbitrary pieces of input
142       from the terminal with a single invocation of cat.  Note, however, that
143       if  standard  input  is a regular file, this would be equivalent to the
144       command:
145
146           cat start − middle /dev/null end > file
147
148       because the entire contents of the file would be consumed  by  cat  the
149       first  time '−' was used as a file operand and an end-of-file condition
150       would be detected immediately when '−' was referenced the second time.
151

RATIONALE

153       Historical versions of the cat utility include  the  −e,  −t,  and  −v,
154       options which permit the ends of lines, <tab> characters, and invisible
155       characters, respectively, to be rendered visible  in  the  output.  The
156       standard developers omitted these options because they provide too fine
157       a degree of control over what is made visible, and similar  output  can
158       be obtained using a command such as:
159
160           sed −n l pathname
161
162       The  latter  also  has  the  advantage  that its output is unambiguous,
163       whereas the output of historical cat −etv is not.
164
165       The −s option was omitted because it corresponds to different functions
166       in  BSD  and System V-based systems. The BSD −s option to squeeze blank
167       lines can be accomplished by the shell script shown  in  the  following
168       example:
169
170           sed −n '
171           # Write non-empty lines.
172           /./   {
173                 p
174                 d
175                 }
176           # Write a single empty line, then look for more empty lines.
177           /^$/  p
178           # Get next line, discard the held <newline> (empty line),
179           # and look for more empty lines.
180           :Empty
181           /^$/  {
182                 N
183                 s/.//
184                 b Empty
185                 }
186           # Write the non-empty line before going back to search
187           # for the first in a set of empty lines.
188                 p
189           '
190
191       The System V −s option to silence error messages can be accomplished by
192       redirecting the standard error. Note that the BSD documentation for cat
193       uses  the  term  ``blank  line''  to mean the same as the POSIX ``empty
194       line'': a line consisting only of a <newline>.
195
196       The BSD −n option was omitted  because  similar  functionality  can  be
197       obtained from the −n option of the pr utility.
198

FUTURE DIRECTIONS

200       None.
201

SEE ALSO

203       more
204
205       The  Base  Definitions  volume  of POSIX.1‐2008, Chapter 8, Environment
206       Variables, Section 12.2, Utility Syntax Guidelines
207
208       The System Interfaces volume of POSIX.1‐2008, setvbuf()
209
211       Portions of this text are reprinted and reproduced in  electronic  form
212       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
213       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
214       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
215       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
216       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
217       event of any discrepancy between this version and the original IEEE and
218       The  Open Group Standard, the original IEEE and The Open Group Standard
219       is the referee document. The original Standard can be  obtained  online
220       at http://www.unix.org/online.html .
221
222       Any  typographical  or  formatting  errors that appear in this page are
223       most likely to have been introduced during the conversion of the source
224       files  to  man page format. To report such errors, see https://www.ker
225       nel.org/doc/man-pages/reporting_bugs.html .
226
227
228
229IEEE/The Open Group                  2013                              CAT(1P)
Impressum