Initial import from FreeBSD RELENG_4:
[dragonfly.git] / usr.bin / paste / paste.1
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. All advertising materials mentioning features or use of this software
17 .\"    must display the following acknowledgement:
18 .\"     This product includes software developed by the University of
19 .\"     California, Berkeley and its contributors.
20 .\" 4. Neither the name of the University nor the names of its contributors
21 .\"    may be used to endorse or promote products derived from this software
22 .\"    without specific prior written permission.
23 .\"
24 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" SUCH DAMAGE.
35 .\"
36 .\"     @(#)paste.1     8.1 (Berkeley) 6/6/93
37 .\" $FreeBSD: src/usr.bin/paste/paste.1,v 1.4.2.8 2003/02/24 23:04:39 trhodes Exp $
38 .\"
39 .Dd September 20, 2001
40 .Dt PASTE 1
41 .Os
42 .Sh NAME
43 .Nm paste
44 .Nd merge corresponding or subsequent lines of files
45 .Sh SYNOPSIS
46 .Nm
47 .Op Fl s
48 .Op Fl d Ar list
49 .Ar
50 .Sh DESCRIPTION
51 The
52 .Nm
53 utility concatenates the corresponding lines of the given input files,
54 replacing all but the last file's newline characters with a single tab
55 character, and writes the resulting lines to standard output.
56 If end-of-file is reached on an input file while other input files
57 still contain data, the file is treated as if it were an endless source
58 of empty lines.
59 .Pp
60 The options are as follows:
61 .Bl -tag -width Fl
62 .It Fl d  Ar list
63 Use one or more of the provided characters to replace the newline
64 characters instead of the default tab.
65 The characters in
66 .Ar list
67 are used circularly, i.e., when
68 .Ar list
69 is exhausted the first character from
70 .Ar list
71 is reused.
72 This continues until a line from the last input file (in default operation)
73 or the last line in each file (using the
74 .Fl s
75 option) is displayed, at which
76 time
77 .Nm
78 begins selecting characters from the beginning of
79 .Ar list
80 again.
81 .Pp
82 The following special characters can also be used in list:
83 .Pp
84 .Bl -tag -width flag -compact
85 .It Li \en
86 newline character
87 .It Li \et
88 tab character
89 .It Li \e\e
90 backslash character
91 .It Li \e0
92 Empty string (not a null character).
93 .El
94 .Pp
95 Any other character preceded by a backslash is equivalent to the
96 character itself.
97 .It Fl s
98 Concatenate all of the lines of each separate input file in command line
99 order.
100 The newline character of every line except the last line in each input
101 file is replaced with the tab character, unless otherwise specified by
102 the
103 .Fl d
104 option.
105 .El
106 .Pp
107 If
108 .Sq Fl
109 is specified for one or more of the input files, the standard
110 input is used; standard input is read one line at a time, circularly,
111 for each instance of
112 .Sq Fl .
113 .Sh EXAMPLES
114 List the files in the current directory in three columns:
115 .Pp
116 .Dl "ls | paste - - -"
117 .Pp
118 Combine pairs of lines from a file into single lines:
119 .Pp
120 .Dl "paste -s -d '\et\en' myfile"
121 .Pp
122 Number the lines in a file, similar to
123 .Xr nl 1 :
124 .Pp
125 .Dl "sed = myfile | paste -s -d '\et\en' - -"
126 .Pp
127 Create a colon-separated list of directories named
128 .Pa bin ,
129 suitable
130 for use in the
131 .Ev PATH
132 environment variable:
133 .Pp
134 .Dl "find / -name bin -type d | paste -s -d : -"
135 .Sh DIAGNOSTICS
136 .Ex -std
137 .Sh SEE ALSO
138 .Xr cut 1 ,
139 .Xr lam 1
140 .Sh STANDARDS
141 The
142 .Nm
143 utility is expected to be
144 .St -p1003.2
145 compatible.
146 .Sh HISTORY
147 A
148 .Nm
149 command appeared in
150 .At 32v .
151 .Sh BUGS
152 Multibyte character delimiters cannot be specified with the
153 .Fl d
154 option.