xref: /freebsd/usr.bin/paste/paste.1 (revision 911f0260390e18cf85f3dbf2c719b593efdc1e3c)
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.\" $FreeBSD$
34.\"
35.Dd November 6, 2022
36.Dt PASTE 1
37.Os
38.Sh NAME
39.Nm paste
40.Nd merge corresponding or subsequent lines of files
41.Sh SYNOPSIS
42.Nm
43.Op Fl s
44.Op Fl d Ar list
45.Ar
46.Sh DESCRIPTION
47The
48.Nm
49utility concatenates the corresponding lines of the given input files,
50replacing all but the last file's newline characters with a single tab
51character, and writes the resulting lines to standard output.
52If end-of-file is reached on an input file while other input files
53still contain data, the file is treated as if it were an endless source
54of empty lines.
55.Pp
56The options are as follows:
57.Bl -tag -width Fl
58.It Fl d Ar list
59Use one or more of the provided characters to replace the newline
60characters instead of the default tab.
61The characters in
62.Ar list
63are used circularly, i.e., when
64.Ar list
65is exhausted the first character from
66.Ar list
67is reused.
68This continues until a line from the last input file (in default operation)
69or the last line in each file (using the
70.Fl s
71option) is displayed, at which
72time
73.Nm
74begins selecting characters from the beginning of
75.Ar list
76again.
77.Pp
78The following special characters can also be used in list:
79.Pp
80.Bl -tag -width flag -compact
81.It Li \en
82newline character
83.It Li \et
84tab character
85.It Li \e\e
86backslash character
87.It Li \e0
88Empty string (not a null character).
89.El
90.Pp
91Any other character preceded by a backslash is equivalent to the
92character itself.
93.It Fl s
94Concatenate all of the lines of each separate input file in command line
95order.
96The newline character of every line except the last line in each input
97file is replaced with the tab character, unless otherwise specified by
98the
99.Fl d
100option.
101.El
102.Pp
103If
104.Sq Fl
105is specified for one or more of the input files, the standard
106input is used; standard input is read one line at a time, circularly,
107for each instance of
108.Sq Fl .
109.Sh EXIT STATUS
110.Ex -std
111.Sh EXAMPLES
112List the files in the current directory in three columns:
113.Pp
114.Dl "ls | paste - - -"
115.Pp
116Combine pairs of lines from a file into single lines:
117.Pp
118.Dl "paste -s -d '\et\en' myfile"
119.Pp
120Number the lines in a file, similar to
121.Xr nl 1 :
122.Pp
123.Dl "sed = myfile | paste - -"
124.Pp
125Create a colon-separated list of directories named
126.Pa bin ,
127suitable
128for use in the
129.Ev PATH
130environment variable:
131.Pp
132.Dl "find / -name bin -type d | paste -s -d : -"
133.Sh SEE ALSO
134.Xr cut 1 ,
135.Xr lam 1
136.Sh STANDARDS
137The
138.Nm
139utility is expected to be
140.St -p1003.2
141compatible.
142.Sh HISTORY
143A
144.Nm
145command first appeared in
146.At III
147and has been available since
148.Bx 4.3 Reno .
149.Sh AUTHORS
150.An -nosplit
151The original Bell Labs version was written by
152.An Gottfried W. R. Luderer
153and the
154.Bx
155version by
156.An Adam S. Moskowitz
157and
158.An Marciano Pitargue .
159