xref: /dragonfly/usr.bin/paste/paste.1 (revision b827281d)
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: head/usr.bin/paste/paste.1 216370 2010-12-11 08:32:16Z joel $
34.\"
35.Dd December 30, 2013
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 ENVIRONMENT
110The
111.Ev LANG , LC_ALL
112and
113.Ev LC_CTYPE
114environment variables affect the execution of
115.Nm
116as described in
117.Xr environ 7 .
118.Sh EXIT STATUS
119.Ex -std
120.Sh EXAMPLES
121List the files in the current directory in three columns:
122.Pp
123.Dl "ls | paste - - -"
124.Pp
125Combine pairs of lines from a file into single lines:
126.Pp
127.Dl "paste -s -d '\et\en' myfile"
128.Pp
129Number the lines in a file, similar to
130.Xr nl 1 :
131.Pp
132.Dl "sed = myfile | paste -s -d '\et\en' - -"
133.Pp
134Create a colon-separated list of directories named
135.Pa bin ,
136suitable
137for use in the
138.Ev PATH
139environment variable:
140.Pp
141.Dl "find / -name bin -type d | paste -s -d : -"
142.Sh SEE ALSO
143.Xr cut 1 ,
144.Xr lam 1
145.Sh STANDARDS
146The
147.Nm
148utility is expected to be
149.St -p1003.2
150compatible.
151.Sh HISTORY
152A
153.Nm
154command appeared in
155.At 32v .
156