1PASTE(1P)                  POSIX Programmer's Manual                 PASTE(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       paste — merge corresponding or subsequent lines of files
14

SYNOPSIS

16       paste [−s] [−d list] file...
17

DESCRIPTION

19       The paste utility shall concatenate  the  corresponding  lines  of  the
20       given input files, and write the resulting lines to standard output.
21
22       The  default  operation  of  paste  shall concatenate the corresponding
23       lines of the input files. The <newline> of every line except  the  line
24       from the last input file shall be replaced with a <tab>.
25
26       If an end-of-file condition is detected on one or more input files, but
27       not all input files, paste shall behave as though empty lines were read
28       from  the files on which end-of-file was detected, unless the −s option
29       is specified.
30

OPTIONS

32       The paste utility shall conform  to  the  Base  Definitions  volume  of
33       POSIX.1‐2008, Section 12.2, Utility Syntax Guidelines.
34
35       The following options shall be supported:
36
37       −d list   Unless  a <backslash> character appears in list, each charac‐
38                 ter in list is an element specifying a  delimiter  character.
39                 If  a  <backslash> character appears in list, the <backslash>
40                 character and one or more characters following it are an ele‐
41                 ment  specifying  a  delimiter  character as described below.
42                 These elements specify one or more delimiters to use, instead
43                 of  the  default <tab>, to replace the <newline> of the input
44                 lines. The elements in list shall be  used  circularly;  that
45                 is,  when  the  list  is exhausted the first element from the
46                 list is reused. When the −s option is specified:
47
48                  *  The last <newline> in a file shall not be modified.
49
50                  *  The delimiter shall be reset to the first element of list
51                     after each file operand is processed.
52
53                 When the −s option is not specified:
54
55                  *  The  <newline>  characters  in  the file specified by the
56                     last file operand shall not be modified.
57
58                  *  The delimiter shall be reset to the first element of list
59                     each time a line is processed from each file.
60
61                 If  a <backslash> character appears in list, it and the char‐
62                 acter following it shall be used to represent  the  following
63                 delimiter characters:
64
65                 \n    <newline>.
66
67                 \t    <tab>.
68
69                 \\    <backslash> character.
70
71                 \0    Empty string (not a null character). If '\0' is immedi‐
72                       ately followed by the character 'x', the character 'X',
73                       or  any character defined by the LC_CTYPE digit keyword
74                       (see the Base Definitions volume of POSIX.1‐2008, Chap‐
75                       ter 7, Locale), the results are unspecified.
76
77                 If  any  other characters follow the <backslash>, the results
78                 are unspecified.
79
80       −s        Concatenate all of the lines of each separate input  file  in
81                 command  line  order.  The <newline> of every line except the
82                 last line in each input  file  shall  be  replaced  with  the
83                 <tab>, unless otherwise specified by the −d option.
84

OPERANDS

86       The following operand shall be supported:
87
88       file      A  pathname  of an input file. If '−' is specified for one or
89                 more of the files, the standard  input  shall  be  used;  the
90                 standard  input shall be read one line at a time, circularly,
91                 for each instance  of  '−'.   Implementations  shall  support
92                 pasting of at least 12 file operands.
93

STDIN

95       The  standard  input shall be used only if one or more file operands is
96       '−'.  See the INPUT FILES section.
97

INPUT FILES

99       The input files shall be text files, except that line lengths shall  be
100       unlimited.
101

ENVIRONMENT VARIABLES

103       The  following  environment  variables  shall  affect  the execution of
104       paste:
105
106       LANG      Provide a default value for  the  internationalization  vari‐
107                 ables  that are unset or null. (See the Base Definitions vol‐
108                 ume of POSIX.1‐2008, Section 8.2, Internationalization  Vari‐
109                 ables  the  precedence of internationalization variables used
110                 to determine the values of locale categories.)
111
112       LC_ALL    If set to a non-empty string value, override  the  values  of
113                 all the other internationalization variables.
114
115       LC_CTYPE  Determine  the  locale for the interpretation of sequences of
116                 bytes of text data as characters (for example, single-byte as
117                 opposed  to  multi-byte  characters  in  arguments  and input
118                 files).
119
120       LC_MESSAGES
121                 Determine the locale that should be used to affect the format
122                 and  contents  of  diagnostic  messages  written  to standard
123                 error.
124
125       NLSPATH   Determine the location of message catalogs for the processing
126                 of LC_MESSAGES.
127

ASYNCHRONOUS EVENTS

129       Default.
130

STDOUT

132       Concatenated  lines  of input files shall be separated by the <tab> (or
133       other characters under the control of the −d option) and terminated  by
134       a <newline>.
135

STDERR

137       The standard error shall be used only for diagnostic messages.
138

OUTPUT FILES

140       None.
141

EXTENDED DESCRIPTION

143       None.
144

EXIT STATUS

146       The following exit values shall be returned:
147
148        0    Successful completion.
149
150       >0    An error occurred.
151

CONSEQUENCES OF ERRORS

153       If  one  or more input files cannot be opened when the −s option is not
154       specified, a diagnostic message shall be written to standard error, but
155       no output is written to standard output. If the −s option is specified,
156       the paste utility shall provide the default behavior described in  Sec‐
157       tion 1.4, Utility Description Defaults.
158
159       The following sections are informative.
160

APPLICATION USAGE

162       When  the  escape  sequences  of the list option-argument are used in a
163       shell script, they must be quoted;  otherwise,  the  shell  treats  the
164       <backslash> as a special character.
165
166       Conforming   applications   should   only   use   the  specific  <back‐
167       slash>-escaped delimiters presented in  this  volume  of  POSIX.1‐2008.
168       Historical  implementations  treat '\x', where 'x' is not in this list,
169       as 'x', but future implementations are free to expand this list to rec‐
170       ognize  other  common  escapes  similar to those accepted by printf and
171       other standard utilities.
172
173       Most of the standard utilities work on text files. The cut utility  can
174       be  used  to  turn files with arbitrary line lengths into a set of text
175       files containing the same data. The paste utility can be used to create
176       (or  recreate)  files with arbitrary line lengths. For example, if file
177       contains long lines:
178
179           cut −b 1−500 −n file > file1
180           cut −b 501− −n file > file2
181
182       creates file1 (a text file) with lines no longer than 500  bytes  (plus
183       the  <newline>)  and file2 that contains the remainder of the data from
184       file.  Note that file2 is not a text file if there are  lines  in  file
185       that  are  longer than 500 + {LINE_MAX} bytes. The original file can be
186       recreated from file1 and file2 using the command:
187
188           paste −d "\0" file1 file2 > file
189
190       The commands:
191
192           paste −d "\0" ...
193           paste −d "" ...
194
195       are not necessarily equivalent; the latter is  not  specified  by  this
196       volume  of  POSIX.1‐2008 and may result in an error. The construct '\0'
197       is used to mean ``no separator'' because historical versions  of  paste
198       did not follow the syntax guidelines, and the command:
199
200           paste −d"" ...
201
202       could not be handled properly by getopt().
203

EXAMPLES

205        1. Write out a directory in four columns:
206
207               ls | paste − − − −
208
209        2. Combine pairs of lines from a file into single lines:
210
211               paste −s −d "\t\n" file
212

RATIONALE

214       None.
215

FUTURE DIRECTIONS

217       None.
218

SEE ALSO

220       Section 1.4, Utility Description Defaults, cut, grep, pr
221
222       The Base Definitions volume of POSIX.1‐2008, Chapter 7, Locale, Chapter
223       8, Environment Variables, Section 12.2, Utility Syntax Guidelines
224
226       Portions of this text are reprinted and reproduced in  electronic  form
227       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
228       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
229       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
230       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
231       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
232       event of any discrepancy between this version and the original IEEE and
233       The  Open Group Standard, the original IEEE and The Open Group Standard
234       is the referee document. The original Standard can be  obtained  online
235       at http://www.unix.org/online.html .
236
237       Any  typographical  or  formatting  errors that appear in this page are
238       most likely to have been introduced during the conversion of the source
239       files  to  man page format. To report such errors, see https://www.ker
240       nel.org/doc/man-pages/reporting_bugs.html .
241
242
243
244IEEE/The Open Group                  2013                            PASTE(1P)
Impressum