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

NAME

6       paste - merge corresponding or subsequent lines of files
7

SYNOPSIS

9       paste [-s][-d list] file...
10

DESCRIPTION

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

OPTIONS

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

OPERANDS

85       The following operand shall be supported:
86
87       file   A pathname of an input file. If '-' is specified for one or more
88              of the files, the standard input shall  be  used;  the  standard
89              input  shall  be  read  one line at a time, circularly, for each
90              instance of '-' . Implementations shall support  pasting  of  at
91              least 12 file operands.
92
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  variables
107              that  are  unset  or  null.  (See the Base Definitions volume of
108              IEEE Std 1003.1-2001, Section  8.2,  Internationalization  Vari‐
109              ables  for 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  all
113              the other internationalization variables.
114
115       LC_CTYPE
116              Determine  the  locale  for  the  interpretation of sequences of
117              bytes of text data as characters (for  example,  single-byte  as
118              opposed to multi-byte characters in arguments and input 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 error.
123
124       NLSPATH
125              Determine the location of message catalogs for the processing of
126              LC_MESSAGES .
127
128

ASYNCHRONOUS EVENTS

130       Default.
131

STDOUT

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

STDERR

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

OUTPUT FILES

141       None.
142

EXTENDED DESCRIPTION

144       None.
145

EXIT STATUS

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

CONSEQUENCES OF ERRORS

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

APPLICATION USAGE

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

EXAMPLES

211        1. Write out a directory in four columns:
212
213
214           ls | paste - - - -
215
216        2. Combine pairs of lines from a file into single lines:
217
218
219           paste -s -d "\t\n" file
220

RATIONALE

222       None.
223

FUTURE DIRECTIONS

225       None.
226

SEE ALSO

228       Utility Description Defaults , cut , grep , pr
229
231       Portions  of  this text are reprinted and reproduced in electronic form
232       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
233       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
234       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
235       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
236       event of any discrepancy between this version and the original IEEE and
237       The  Open Group Standard, the original IEEE and The Open Group Standard
238       is the referee document. The original Standard can be  obtained  online
239       at http://www.opengroup.org/unix/online.html .
240
241
242
243IEEE/The Open Group                  2003                             PASTE(P)
Impressum