logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git

paste.1 (4743B)


  1. .\" SPDX-License-Identifier: BSD-3-Clause
  2. .\"
  3. .\" Copyright (c) 1989, 1990, 1993
  4. .\" The Regents of the University of California. All rights reserved.
  5. .\"
  6. .\" This code is derived from software contributed to Berkeley by
  7. .\" Adam S. Moskowitz and the Institute of Electrical and Electronics
  8. .\" Engineers, Inc.
  9. .\"
  10. .\" Redistribution and use in source and binary forms, with or without
  11. .\" modification, are permitted provided that the following conditions
  12. .\" are met:
  13. .\" 1. Redistributions of source code must retain the above copyright
  14. .\" notice, this list of conditions and the following disclaimer.
  15. .\" 2. Redistributions in binary form must reproduce the above copyright
  16. .\" notice, this list of conditions and the following disclaimer in the
  17. .\" documentation and/or other materials provided with the distribution.
  18. .\" 3. Neither the name of the University nor the names of its contributors
  19. .\" may be used to endorse or promote products derived from this software
  20. .\" without specific prior written permission.
  21. .\"
  22. .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  23. .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  26. .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  28. .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  29. .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  31. .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. .\" SUCH DAMAGE.
  33. .\"
  34. .\" @(#)paste.1 8.1 (Berkeley) 6/6/93
  35. .\"
  36. .Dd November 6, 2022
  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 sz
  45. .Op Fl d Ar list
  46. .Op Ar file...
  47. .Sh DESCRIPTION
  48. The
  49. .Nm
  50. utility concatenates the corresponding lines of the given
  51. .Ar file ,
  52. replacing all but the last file's newline characters with a single tab
  53. character, and writes the resulting lines to standard output.
  54. If end-of-file is reached on an input file while other
  55. .Ar file
  56. still contain data, the file is treated as if it were an endless source
  57. of empty lines.
  58. .Pp
  59. If no
  60. .Ar file
  61. is passed, standard input is read instead.
  62. .Sh OPTIONS
  63. The options are as follows:
  64. .Bl -tag -width Fl
  65. .It Fl d Ar list
  66. Use one or more of the provided characters to replace the newline
  67. characters instead of the default tab.
  68. The characters in
  69. .Ar list
  70. are used circularly, i.e., when
  71. .Ar list
  72. is exhausted the first character from
  73. .Ar list
  74. is reused.
  75. This continues until a line from the last input file (in default operation)
  76. or the last line in each file (using the
  77. .Fl s
  78. option) is displayed, at which
  79. time
  80. .Nm
  81. begins selecting characters from the beginning of
  82. .Ar list
  83. again.
  84. .Pp
  85. The following special characters can also be used in list:
  86. .Pp
  87. .Bl -tag -width flag -compact
  88. .It Li \en
  89. newline character
  90. .It Li \et
  91. tab character
  92. .It Li \e\e
  93. backslash character
  94. .It Li \e0
  95. Empty string (not a null character).
  96. .El
  97. .Pp
  98. Any other character preceded by a backslash is equivalent to the
  99. character itself.
  100. .It Fl s
  101. Concatenate all of the lines of each separate input file in command line
  102. order.
  103. The newline character of every line except the last line in each input
  104. file is replaced with the tab character, unless otherwise specified by
  105. the
  106. .Fl d
  107. option.
  108. .It Fl z
  109. Delimiter is NULL not newline.
  110. .El
  111. .Pp
  112. If
  113. .Sq Fl
  114. is passed to one or more
  115. .Ar file
  116. argument, the standard input is used; standard input is read one line at a time, circularly,
  117. for each instance of
  118. .Sq Fl .
  119. .Sh EXIT STATUS
  120. .Ex -std
  121. .Sh EXAMPLES
  122. List the files in the current directory in three columns:
  123. .Pp
  124. .Dl "ls | paste - - -"
  125. .Pp
  126. Combine pairs of lines from a file into single lines:
  127. .Pp
  128. .Dl "paste -s -d '\et\en' myfile"
  129. .Pp
  130. Number the lines in a file, similar to
  131. .Xr nl 1 :
  132. .Pp
  133. .Dl "sed = myfile | paste - -"
  134. .Pp
  135. Create a colon-separated list of directories named
  136. .Pa bin ,
  137. suitable
  138. for use in the
  139. .Ev PATH
  140. environment variable:
  141. .Pp
  142. .Dl "find / -name bin -type d | paste -s -d : -"
  143. .Sh SEE ALSO
  144. .Xr cut 1
  145. .Sh STANDARDS
  146. .Nm
  147. should be compliant with the
  148. IEEE Std 1003.1-2024 (“POSIX.1”)
  149. specification.
  150. .Pp
  151. Usage with no
  152. .Ar file
  153. passed and the
  154. .Fl z
  155. option are extensions.
  156. .Sh HISTORY
  157. A
  158. .Nm
  159. command first appeared in
  160. .At III
  161. and has been available since
  162. .Bx 4.3 Reno .
  163. .Sh AUTHORS
  164. .An -nosplit
  165. The original Bell Labs version was written by
  166. .An Gottfried W. R. Luderer
  167. and the
  168. .Bx
  169. version by
  170. .An Adam S. Moskowitz
  171. and
  172. .An Marciano Pitargue .