xref: /freebsd/usr.bin/paste/paste.1 (revision cbb3ec25236ba72f91cbdf23f8b78b9d1af0cedf)
1.\" Copyright (c) 1989, 1990, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Adam S. Moskowitz and the Institute of Electrical and Electronics
6.\" Engineers, Inc.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\" 3. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"	@(#)paste.1	8.1 (Berkeley) 6/6/93
33.\"
34.Dd November 6, 2022
35.Dt PASTE 1
36.Os
37.Sh NAME
38.Nm paste
39.Nd merge corresponding or subsequent lines of files
40.Sh SYNOPSIS
41.Nm
42.Op Fl s
43.Op Fl d Ar list
44.Ar
45.Sh DESCRIPTION
46The
47.Nm
48utility concatenates the corresponding lines of the given input files,
49replacing all but the last file's newline characters with a single tab
50character, and writes the resulting lines to standard output.
51If end-of-file is reached on an input file while other input files
52still contain data, the file is treated as if it were an endless source
53of empty lines.
54.Pp
55The options are as follows:
56.Bl -tag -width Fl
57.It Fl d Ar list
58Use one or more of the provided characters to replace the newline
59characters instead of the default tab.
60The characters in
61.Ar list
62are used circularly, i.e., when
63.Ar list
64is exhausted the first character from
65.Ar list
66is reused.
67This continues until a line from the last input file (in default operation)
68or the last line in each file (using the
69.Fl s
70option) is displayed, at which
71time
72.Nm
73begins selecting characters from the beginning of
74.Ar list
75again.
76.Pp
77The following special characters can also be used in list:
78.Pp
79.Bl -tag -width flag -compact
80.It Li \en
81newline character
82.It Li \et
83tab character
84.It Li \e\e
85backslash character
86.It Li \e0
87Empty string (not a null character).
88.El
89.Pp
90Any other character preceded by a backslash is equivalent to the
91character itself.
92.It Fl s
93Concatenate all of the lines of each separate input file in command line
94order.
95The newline character of every line except the last line in each input
96file is replaced with the tab character, unless otherwise specified by
97the
98.Fl d
99option.
100.El
101.Pp
102If
103.Sq Fl
104is specified for one or more of the input files, the standard
105input is used; standard input is read one line at a time, circularly,
106for each instance of
107.Sq Fl .
108.Sh EXIT STATUS
109.Ex -std
110.Sh EXAMPLES
111List the files in the current directory in three columns:
112.Pp
113.Dl "ls | paste - - -"
114.Pp
115Combine pairs of lines from a file into single lines:
116.Pp
117.Dl "paste -s -d '\et\en' myfile"
118.Pp
119Number the lines in a file, similar to
120.Xr nl 1 :
121.Pp
122.Dl "sed = myfile | paste - -"
123.Pp
124Create a colon-separated list of directories named
125.Pa bin ,
126suitable
127for use in the
128.Ev PATH
129environment variable:
130.Pp
131.Dl "find / -name bin -type d | paste -s -d : -"
132.Sh SEE ALSO
133.Xr cut 1 ,
134.Xr lam 1
135.Sh STANDARDS
136The
137.Nm
138utility is expected to be
139.St -p1003.2
140compatible.
141.Sh HISTORY
142A
143.Nm
144command first appeared in
145.At III
146and has been available since
147.Bx 4.3 Reno .
148.Sh AUTHORS
149.An -nosplit
150The original Bell Labs version was written by
151.An Gottfried W. R. Luderer
152and the
153.Bx
154version by
155.An Adam S. Moskowitz
156and
157.An Marciano Pitargue .
158