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

NAME

12       cat - concatenate and print files
13

SYNOPSIS

15       cat [-u][file ...]
16

DESCRIPTION

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

OPTIONS

22       The  cat  utility  shall  conform  to  the  Base  Definitions volume of
23       IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
24
25       The following option shall be supported:
26
27       -u     Write bytes from the input file to the standard  output  without
28              delay as each is read.
29
30

OPERANDS

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

STDIN

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

INPUT FILES

47       The input files can be any file type.
48

ENVIRONMENT VARIABLES

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

ASYNCHRONOUS EVENTS

76       Default.
77

STDOUT

79       The standard output shall contain the sequence of bytes read  from  the
80       input files. Nothing else shall be written to the standard output.
81

STDERR

83       The standard error shall be used only for diagnostic messages.
84

OUTPUT FILES

86       None.
87

EXTENDED DESCRIPTION

89       None.
90

EXIT STATUS

92       The following exit values shall be returned:
93
94        0     All input files were output successfully.
95
96       >0     An error occurred.
97
98

CONSEQUENCES OF ERRORS

100       Default.
101
102       The following sections are informative.
103

APPLICATION USAGE

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

EXAMPLES

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

RATIONALE

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

FUTURE DIRECTIONS

208       None.
209

SEE ALSO

211       more, the System Interfaces volume of IEEE Std 1003.1-2001, setvbuf()
212
214       Portions  of  this text are reprinted and reproduced in electronic form
215       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
216       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
217       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
218       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
219       event of any discrepancy between this version and the original IEEE and
220       The  Open Group Standard, the original IEEE and The Open Group Standard
221       is the referee document. The original Standard can be  obtained  online
222       at http://www.opengroup.org/unix/online.html .
223
224
225
226IEEE/The Open Group                  2003                              CAT(1P)
Impressum