summaryrefslogtreecommitdiffstats
path: root/man-pages-posix-2017/man1p/paste.1p
blob: 91ee9c6c67856c9b4c80844737809b343b0dcf97 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
'\" et
.TH PASTE "1P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\"
.SH PROLOG
This manual page is part of the POSIX Programmer's Manual.
The Linux implementation of this interface may differ (consult
the corresponding Linux manual page for details of Linux behavior),
or the interface may not be implemented on Linux.
.\"
.SH NAME
paste
\(em merge corresponding or subsequent lines of files
.SH SYNOPSIS
.LP
.nf
paste \fB[\fR-s\fB] [\fR-d \fIlist\fB] \fIfile\fR...
.fi
.SH DESCRIPTION
The
.IR paste
utility shall concatenate the corresponding lines of the given input
files, and write the resulting lines to standard output.
.P
The default operation of
.IR paste
shall concatenate the corresponding lines of the input files. The
<newline>
of every line except the line from the last input file shall be
replaced with a
<tab>.
.P
If an end-of-file condition is detected on one or more input files, but
not all input files,
.IR paste
shall behave as though empty lines were read from the files on which
end-of-file was detected, unless the
.BR \-s
option is specified.
.SH OPTIONS
The
.IR paste
utility shall conform to the Base Definitions volume of POSIX.1\(hy2017,
.IR "Section 12.2" ", " "Utility Syntax Guidelines".
.P
The following options shall be supported:
.IP "\fB\-d\ \fIlist\fR" 10
Unless a
<backslash>
character appears in
.IR list ,
each character in
.IR list
is an element specifying a delimiter character. If a
<backslash>
character appears in
.IR list ,
the
<backslash>
character and one or more characters following it are an element
specifying a delimiter character as described below. These elements
specify one or more delimiters to use, instead of the default
<tab>,
to replace the
<newline>
of the input lines. The elements in
.IR list
shall be used circularly; that is, when the list is exhausted the first
element from the list is reused. When the
.BR \-s
option is specified:
.RS 10 
.IP " *" 4
The last
<newline>
in a file shall not be modified.
.IP " *" 4
The delimiter shall be reset to the first element of
.IR list
after each
.IR file
operand is processed.
.P
When the
.BR \-s
option is not specified:
.IP " *" 4
The
<newline>
characters in the file specified by the last
.IR file
operand shall not be modified.
.IP " *" 4
The delimiter shall be reset to the first element of list each time a
line is processed from each file.
.P
If a
<backslash>
character appears in
.IR list ,
it and the character following it shall be used to represent the
following delimiter characters:
.IP "\fR\en\fR" 6
<newline>.
.IP "\fR\et\fR" 6
<tab>.
.IP "\fR\e\e\fR" 6
<backslash>
character.
.IP "\fR\e0\fR" 6
Empty string (not a null character). If
.BR '\e0' 
is immediately followed by the character
.BR 'x' ,
the character
.BR 'X' ,
or any character defined by the
.IR LC_CTYPE
.BR digit
keyword (see the Base Definitions volume of POSIX.1\(hy2017,
.IR "Chapter 7" ", " "Locale"),
the results are unspecified.
.P
If any other characters follow the
<backslash>,
the results are unspecified.
.RE
.IP "\fB\-s\fP" 10
Concatenate all of the lines from each input file into one line of
output per file, in command line order. The
<newline>
of every line except the last line in each input file shall be replaced
with a
<tab>,
unless otherwise specified by the
.BR \-d
option. If an input file is empty, the output line corresponding to
that file shall consist of only a
<newline>
character.
.SH OPERANDS
The following operand shall be supported:
.IP "\fIfile\fR" 10
A pathname of an input file. If
.BR '\-' 
is specified for one or more of the
.IR file s,
the standard input shall be used; the standard input shall be read one
line at a time, circularly, for each instance of
.BR '\-' .
Implementations shall support pasting of at least 12
.IR file
operands.
.SH STDIN
The standard input shall be used only if one or more
.IR file
operands is
.BR '\-' .
See the INPUT FILES section.
.SH "INPUT FILES"
The input files shall be text files, except that line lengths shall be
unlimited.
.SH "ENVIRONMENT VARIABLES"
The following environment variables shall affect the execution of
.IR paste :
.IP "\fILANG\fP" 10
Provide a default value for the internationalization variables that are
unset or null. (See the Base Definitions volume of POSIX.1\(hy2017,
.IR "Section 8.2" ", " "Internationalization Variables"
the precedence of internationalization variables used to determine the
values of locale categories.)
.IP "\fILC_ALL\fP" 10
If set to a non-empty string value, override the values of all the
other internationalization variables.
.IP "\fILC_CTYPE\fP" 10
Determine the locale for the interpretation of sequences of bytes of
text data as characters (for example, single-byte as opposed to
multi-byte characters in arguments and input files).
.IP "\fILC_MESSAGES\fP" 10
.br
Determine the locale that should be used to affect the format and
contents of diagnostic messages written to standard error.
.IP "\fINLSPATH\fP" 10
Determine the location of message catalogs for the processing of
.IR LC_MESSAGES .
.SH "ASYNCHRONOUS EVENTS"
Default.
.SH STDOUT
Concatenated lines of input files shall be separated by the
<tab>
(or other characters under the control of the
.BR \-d
option) and terminated by a
<newline>.
.SH STDERR
The standard error shall be used only for diagnostic messages.
.SH "OUTPUT FILES"
None.
.SH "EXTENDED DESCRIPTION"
None.
.SH "EXIT STATUS"
The following exit values shall be returned:
.IP "\00" 6
Successful completion.
.IP >0 6
An error occurred.
.SH "CONSEQUENCES OF ERRORS"
If one or more input files cannot be opened when the
.BR \-s
option is not specified, a diagnostic message shall be written to
standard error, but no output is written to standard output. If the
.BR \-s
option is specified, the
.IR paste
utility shall provide the default behavior described in
.IR "Section 1.4" ", " "Utility Description Defaults".
.LP
.IR "The following sections are informative."
.SH "APPLICATION USAGE"
When the escape sequences of the
.IR list
option-argument are used in a shell script, they must be quoted;
otherwise, the shell treats the
<backslash>
as a special character.
.P
Conforming applications should only use the specific
<backslash>-escaped
delimiters presented in this volume of POSIX.1\(hy2017. Historical implementations treat
.BR '\ex' ,
where
.BR 'x' 
is not in this list, as
.BR 'x' ,
but future implementations are free to expand this list to recognize
other common escapes similar to those accepted by
.IR printf
and other standard utilities.
.P
Most of the standard utilities work on text files. The
.IR cut
utility can be used to turn files with arbitrary line lengths into a
set of text files containing the same data. The
.IR paste
utility can be used to create (or recreate) files with arbitrary line
lengths. For example, if
.IR file
contains long lines:
.sp
.RS 4
.nf

cut -b 1-500 -n file > file1
cut -b 501- -n file > file2
.fi
.P
.RE
.P
creates
.BR file1
(a text file) with lines no longer than 500 bytes (plus the
<newline>)
and
.BR file2
that contains the remainder of the data from
.IR file .
Note that
.BR file2
is not a text file if there are lines in
.IR file
that are longer than 500 +
{LINE_MAX}
bytes. The original file can be recreated from
.BR file1
and
.BR file2
using the command:
.sp
.RS 4
.nf

paste -d "\e0" file1 file2 > file
.fi
.P
.RE
.P
The commands:
.sp
.RS 4
.nf

paste -d "\e0" ...
paste -d "" ...
.fi
.P
.RE
.P
are not necessarily equivalent; the latter is not specified by this volume of POSIX.1\(hy2017
and may result in an error. The construct
.BR '\e0' 
is used to mean ``no separator'' because historical versions of
.IR paste
did not follow the syntax guidelines, and the command:
.sp
.RS 4
.nf

paste -d"" ...
.fi
.P
.RE
.P
could not be handled properly by
\fIgetopt\fR().
.SH EXAMPLES
.IP " 1." 4
Write out a directory in four columns:
.RS 4 
.sp
.RS 4
.nf

ls | paste - - - -
.fi
.P
.RE
.RE
.IP " 2." 4
Combine pairs of lines from a file into single lines:
.RS 4 
.sp
.RS 4
.nf

paste -s -d "\et\en" file
.fi
.P
.RE
.RE
.SH RATIONALE
None.
.SH "FUTURE DIRECTIONS"
None.
.SH "SEE ALSO"
.IR "Section 1.4" ", " "Utility Description Defaults",
.IR "\fIcut\fR\^",
.IR "\fIgrep\fR\^",
.IR "\fIpr\fR\^"
.P
The Base Definitions volume of POSIX.1\(hy2017,
.IR "Chapter 7" ", " "Locale",
.IR "Chapter 8" ", " "Environment Variables",
.IR "Section 12.2" ", " "Utility Syntax Guidelines"
.\"
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1-2017, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 7, 2018 Edition,
Copyright (C) 2018 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group.
In the event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .
.PP
Any typographical or formatting errors that appear
in this page are most likely
to have been introduced during the conversion of the source files to
man page format. To report such errors, see
https://www.kernel.org/doc/man-pages/reporting_bugs.html .