xref: /freebsd/usr.bin/paste/paste.1 (revision bdcbfde31e8e9b343f113a1956384bdf30d1ed62)
19b50d902SRodney W. Grimes.\" Copyright (c) 1989, 1990, 1993
29b50d902SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
39b50d902SRodney W. Grimes.\"
49b50d902SRodney W. Grimes.\" This code is derived from software contributed to Berkeley by
59b50d902SRodney W. Grimes.\" Adam S. Moskowitz and the Institute of Electrical and Electronics
69b50d902SRodney W. Grimes.\" Engineers, Inc.
79b50d902SRodney W. Grimes.\"
89b50d902SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
99b50d902SRodney W. Grimes.\" modification, are permitted provided that the following conditions
109b50d902SRodney W. Grimes.\" are met:
119b50d902SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
129b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
139b50d902SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
149b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
159b50d902SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
16fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors
179b50d902SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
189b50d902SRodney W. Grimes.\"    without specific prior written permission.
199b50d902SRodney W. Grimes.\"
209b50d902SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
219b50d902SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
229b50d902SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
239b50d902SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
249b50d902SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
259b50d902SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
269b50d902SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
279b50d902SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
289b50d902SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
299b50d902SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
309b50d902SRodney W. Grimes.\" SUCH DAMAGE.
319b50d902SRodney W. Grimes.\"
32*9bdb5158SGordon Bergling.Dd November 6, 2022
339b50d902SRodney W. Grimes.Dt PASTE 1
349b50d902SRodney W. Grimes.Os
359b50d902SRodney W. Grimes.Sh NAME
369b50d902SRodney W. Grimes.Nm paste
379b50d902SRodney W. Grimes.Nd merge corresponding or subsequent lines of files
389b50d902SRodney W. Grimes.Sh SYNOPSIS
391e133604SPhilippe Charnier.Nm
409b50d902SRodney W. Grimes.Op Fl s
419b50d902SRodney W. Grimes.Op Fl d Ar list
4247dec781SRuslan Ermilov.Ar
439b50d902SRodney W. Grimes.Sh DESCRIPTION
449b50d902SRodney W. GrimesThe
451e133604SPhilippe Charnier.Nm
469b50d902SRodney W. Grimesutility concatenates the corresponding lines of the given input files,
479b50d902SRodney W. Grimesreplacing all but the last file's newline characters with a single tab
489b50d902SRodney W. Grimescharacter, and writes the resulting lines to standard output.
499b50d902SRodney W. GrimesIf end-of-file is reached on an input file while other input files
509b50d902SRodney W. Grimesstill contain data, the file is treated as if it were an endless source
519b50d902SRodney W. Grimesof empty lines.
529b50d902SRodney W. Grimes.Pp
539b50d902SRodney W. GrimesThe options are as follows:
549b50d902SRodney W. Grimes.Bl -tag -width Fl
559b50d902SRodney W. Grimes.It Fl d Ar list
569b50d902SRodney W. GrimesUse one or more of the provided characters to replace the newline
579b50d902SRodney W. Grimescharacters instead of the default tab.
589b50d902SRodney W. GrimesThe characters in
599b50d902SRodney W. Grimes.Ar list
609b50d902SRodney W. Grimesare used circularly, i.e., when
619b50d902SRodney W. Grimes.Ar list
629b50d902SRodney W. Grimesis exhausted the first character from
639b50d902SRodney W. Grimes.Ar list
649b50d902SRodney W. Grimesis reused.
659b50d902SRodney W. GrimesThis continues until a line from the last input file (in default operation)
664ed31d66SPhilippe Charnieror the last line in each file (using the
674ed31d66SPhilippe Charnier.Fl s
684ed31d66SPhilippe Charnieroption) is displayed, at which
699b50d902SRodney W. Grimestime
701e133604SPhilippe Charnier.Nm
719b50d902SRodney W. Grimesbegins selecting characters from the beginning of
729b50d902SRodney W. Grimes.Ar list
739b50d902SRodney W. Grimesagain.
749b50d902SRodney W. Grimes.Pp
759b50d902SRodney W. GrimesThe following special characters can also be used in list:
769b50d902SRodney W. Grimes.Pp
779b50d902SRodney W. Grimes.Bl -tag -width flag -compact
789b50d902SRodney W. Grimes.It Li \en
799b50d902SRodney W. Grimesnewline character
809b50d902SRodney W. Grimes.It Li \et
819b50d902SRodney W. Grimestab character
829b50d902SRodney W. Grimes.It Li \e\e
839b50d902SRodney W. Grimesbackslash character
849b50d902SRodney W. Grimes.It Li \e0
859b50d902SRodney W. GrimesEmpty string (not a null character).
869b50d902SRodney W. Grimes.El
879b50d902SRodney W. Grimes.Pp
889b50d902SRodney W. GrimesAny other character preceded by a backslash is equivalent to the
899b50d902SRodney W. Grimescharacter itself.
909b50d902SRodney W. Grimes.It Fl s
919b50d902SRodney W. GrimesConcatenate all of the lines of each separate input file in command line
929b50d902SRodney W. Grimesorder.
939b50d902SRodney W. GrimesThe newline character of every line except the last line in each input
949b50d902SRodney W. Grimesfile is replaced with the tab character, unless otherwise specified by
954ed31d66SPhilippe Charnierthe
964ed31d66SPhilippe Charnier.Fl d
974ed31d66SPhilippe Charnieroption.
989b50d902SRodney W. Grimes.El
999b50d902SRodney W. Grimes.Pp
1009b50d902SRodney W. GrimesIf
101463cfa80SRuslan Ermilov.Sq Fl
1029b50d902SRodney W. Grimesis specified for one or more of the input files, the standard
1039b50d902SRodney W. Grimesinput is used; standard input is read one line at a time, circularly,
1049b50d902SRodney W. Grimesfor each instance of
105463cfa80SRuslan Ermilov.Sq Fl .
1066c7216dfSRuslan Ermilov.Sh EXIT STATUS
1076c7216dfSRuslan Ermilov.Ex -std
10876d70052STim J. Robbins.Sh EXAMPLES
10976d70052STim J. RobbinsList the files in the current directory in three columns:
11076d70052STim J. Robbins.Pp
11176d70052STim J. Robbins.Dl "ls | paste - - -"
11276d70052STim J. Robbins.Pp
11376d70052STim J. RobbinsCombine pairs of lines from a file into single lines:
11476d70052STim J. Robbins.Pp
11576d70052STim J. Robbins.Dl "paste -s -d '\et\en' myfile"
11676d70052STim J. Robbins.Pp
11776d70052STim J. RobbinsNumber the lines in a file, similar to
11876d70052STim J. Robbins.Xr nl 1 :
11976d70052STim J. Robbins.Pp
1208790fe30Sjocki84.Dl "sed = myfile | paste - -"
121851623f4SJuli Mallett.Pp
12206e482e6SRuslan ErmilovCreate a colon-separated list of directories named
12306e482e6SRuslan Ermilov.Pa bin ,
12406e482e6SRuslan Ermilovsuitable
125851623f4SJuli Mallettfor use in the
126851623f4SJuli Mallett.Ev PATH
127851623f4SJuli Mallettenvironment variable:
128851623f4SJuli Mallett.Pp
129851623f4SJuli Mallett.Dl "find / -name bin -type d | paste -s -d : -"
1309b50d902SRodney W. Grimes.Sh SEE ALSO
131748dcfb0SGarrett Wollman.Xr cut 1 ,
132748dcfb0SGarrett Wollman.Xr lam 1
1339b50d902SRodney W. Grimes.Sh STANDARDS
1349b50d902SRodney W. GrimesThe
1351e133604SPhilippe Charnier.Nm
1369b50d902SRodney W. Grimesutility is expected to be
1379b50d902SRodney W. Grimes.St -p1003.2
1389b50d902SRodney W. Grimescompatible.
13930f8b6c1STim J. Robbins.Sh HISTORY
14030f8b6c1STim J. RobbinsA
14130f8b6c1STim J. Robbins.Nm
142*9bdb5158SGordon Berglingcommand first appeared in
143*9bdb5158SGordon Bergling.At III
144*9bdb5158SGordon Berglingand has been available since
145*9bdb5158SGordon Bergling.Bx 4.3 Reno .
146*9bdb5158SGordon Bergling.Sh AUTHORS
147*9bdb5158SGordon Bergling.An -nosplit
148*9bdb5158SGordon BerglingThe original Bell Labs version was written by
149*9bdb5158SGordon Bergling.An Gottfried W. R. Luderer
150*9bdb5158SGordon Berglingand the
151*9bdb5158SGordon Bergling.Bx
152*9bdb5158SGordon Berglingversion by
153*9bdb5158SGordon Bergling.An Adam S. Moskowitz
154*9bdb5158SGordon Berglingand
155*9bdb5158SGordon Bergling.An Marciano Pitargue .
156