xref: /freebsd/usr.bin/paste/paste.1 (revision fbbd9655e5107c68e4e0146ff22b73d7350475bc)
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.
16*fbbd9655SWarner 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.\"
329b50d902SRodney W. Grimes.\"	@(#)paste.1	8.1 (Berkeley) 6/6/93
33c3aac50fSPeter Wemm.\" $FreeBSD$
349b50d902SRodney W. Grimes.\"
350f10c7bbSTim J. Robbins.Dd June 25, 2004
369b50d902SRodney W. Grimes.Dt PASTE 1
379b50d902SRodney W. Grimes.Os
389b50d902SRodney W. Grimes.Sh NAME
399b50d902SRodney W. Grimes.Nm paste
409b50d902SRodney W. Grimes.Nd merge corresponding or subsequent lines of files
419b50d902SRodney W. Grimes.Sh SYNOPSIS
421e133604SPhilippe Charnier.Nm
439b50d902SRodney W. Grimes.Op Fl s
449b50d902SRodney W. Grimes.Op Fl d Ar list
4547dec781SRuslan Ermilov.Ar
469b50d902SRodney W. Grimes.Sh DESCRIPTION
479b50d902SRodney W. GrimesThe
481e133604SPhilippe Charnier.Nm
499b50d902SRodney W. Grimesutility concatenates the corresponding lines of the given input files,
509b50d902SRodney W. Grimesreplacing all but the last file's newline characters with a single tab
519b50d902SRodney W. Grimescharacter, and writes the resulting lines to standard output.
529b50d902SRodney W. GrimesIf end-of-file is reached on an input file while other input files
539b50d902SRodney W. Grimesstill contain data, the file is treated as if it were an endless source
549b50d902SRodney W. Grimesof empty lines.
559b50d902SRodney W. Grimes.Pp
569b50d902SRodney W. GrimesThe options are as follows:
579b50d902SRodney W. Grimes.Bl -tag -width Fl
589b50d902SRodney W. Grimes.It Fl d Ar list
599b50d902SRodney W. GrimesUse one or more of the provided characters to replace the newline
609b50d902SRodney W. Grimescharacters instead of the default tab.
619b50d902SRodney W. GrimesThe characters in
629b50d902SRodney W. Grimes.Ar list
639b50d902SRodney W. Grimesare used circularly, i.e., when
649b50d902SRodney W. Grimes.Ar list
659b50d902SRodney W. Grimesis exhausted the first character from
669b50d902SRodney W. Grimes.Ar list
679b50d902SRodney W. Grimesis reused.
689b50d902SRodney W. GrimesThis continues until a line from the last input file (in default operation)
694ed31d66SPhilippe Charnieror the last line in each file (using the
704ed31d66SPhilippe Charnier.Fl s
714ed31d66SPhilippe Charnieroption) is displayed, at which
729b50d902SRodney W. Grimestime
731e133604SPhilippe Charnier.Nm
749b50d902SRodney W. Grimesbegins selecting characters from the beginning of
759b50d902SRodney W. Grimes.Ar list
769b50d902SRodney W. Grimesagain.
779b50d902SRodney W. Grimes.Pp
789b50d902SRodney W. GrimesThe following special characters can also be used in list:
799b50d902SRodney W. Grimes.Pp
809b50d902SRodney W. Grimes.Bl -tag -width flag -compact
819b50d902SRodney W. Grimes.It Li \en
829b50d902SRodney W. Grimesnewline character
839b50d902SRodney W. Grimes.It Li \et
849b50d902SRodney W. Grimestab character
859b50d902SRodney W. Grimes.It Li \e\e
869b50d902SRodney W. Grimesbackslash character
879b50d902SRodney W. Grimes.It Li \e0
889b50d902SRodney W. GrimesEmpty string (not a null character).
899b50d902SRodney W. Grimes.El
909b50d902SRodney W. Grimes.Pp
919b50d902SRodney W. GrimesAny other character preceded by a backslash is equivalent to the
929b50d902SRodney W. Grimescharacter itself.
939b50d902SRodney W. Grimes.It Fl s
949b50d902SRodney W. GrimesConcatenate all of the lines of each separate input file in command line
959b50d902SRodney W. Grimesorder.
969b50d902SRodney W. GrimesThe newline character of every line except the last line in each input
979b50d902SRodney W. Grimesfile is replaced with the tab character, unless otherwise specified by
984ed31d66SPhilippe Charnierthe
994ed31d66SPhilippe Charnier.Fl d
1004ed31d66SPhilippe Charnieroption.
1019b50d902SRodney W. Grimes.El
1029b50d902SRodney W. Grimes.Pp
1039b50d902SRodney W. GrimesIf
104463cfa80SRuslan Ermilov.Sq Fl
1059b50d902SRodney W. Grimesis specified for one or more of the input files, the standard
1069b50d902SRodney W. Grimesinput is used; standard input is read one line at a time, circularly,
1079b50d902SRodney W. Grimesfor each instance of
108463cfa80SRuslan Ermilov.Sq Fl .
1096c7216dfSRuslan Ermilov.Sh EXIT STATUS
1106c7216dfSRuslan Ermilov.Ex -std
11176d70052STim J. Robbins.Sh EXAMPLES
11276d70052STim J. RobbinsList the files in the current directory in three columns:
11376d70052STim J. Robbins.Pp
11476d70052STim J. Robbins.Dl "ls | paste - - -"
11576d70052STim J. Robbins.Pp
11676d70052STim J. RobbinsCombine pairs of lines from a file into single lines:
11776d70052STim J. Robbins.Pp
11876d70052STim J. Robbins.Dl "paste -s -d '\et\en' myfile"
11976d70052STim J. Robbins.Pp
12076d70052STim J. RobbinsNumber the lines in a file, similar to
12176d70052STim J. Robbins.Xr nl 1 :
12276d70052STim J. Robbins.Pp
12376d70052STim J. Robbins.Dl "sed = myfile | paste -s -d '\et\en' - -"
124851623f4SJuli Mallett.Pp
12506e482e6SRuslan ErmilovCreate a colon-separated list of directories named
12606e482e6SRuslan Ermilov.Pa bin ,
12706e482e6SRuslan Ermilovsuitable
128851623f4SJuli Mallettfor use in the
129851623f4SJuli Mallett.Ev PATH
130851623f4SJuli Mallettenvironment variable:
131851623f4SJuli Mallett.Pp
132851623f4SJuli Mallett.Dl "find / -name bin -type d | paste -s -d : -"
1339b50d902SRodney W. Grimes.Sh SEE ALSO
134748dcfb0SGarrett Wollman.Xr cut 1 ,
135748dcfb0SGarrett Wollman.Xr lam 1
1369b50d902SRodney W. Grimes.Sh STANDARDS
1379b50d902SRodney W. GrimesThe
1381e133604SPhilippe Charnier.Nm
1399b50d902SRodney W. Grimesutility is expected to be
1409b50d902SRodney W. Grimes.St -p1003.2
1419b50d902SRodney W. Grimescompatible.
14230f8b6c1STim J. Robbins.Sh HISTORY
14330f8b6c1STim J. RobbinsA
14430f8b6c1STim J. Robbins.Nm
14530f8b6c1STim J. Robbinscommand appeared in
14630f8b6c1STim J. Robbins.At 32v .
147