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