theshell.ch/site/pages/cmd/advanced/paste-cat.html
montiag 0dbd4778df advanced:paste-cat
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@247 a672b425-5310-4d7a-af5c-997e18724b81
2018-11-18 12:28:06 +00:00

59 lines
2.1 KiB
HTML

---
layout: page
author: Agostino Monti
category-page: advanced
category-title: Advanced commands
tags: filie coluns analize
title: paste
---
<br>
<br>
<p><code>paste</code> is a Unix command line utility which is used to join files horizontally
(parallel merging) by outputting lines consisting of the sequentially corresponding
lines of each file specified, separated by tabs, to the standard output.
Once involved, <code>paste</code> will read all its file arguments. For each corresponding line,
paste will append the contents of each file at that line to its output along with a tab.
When it has completed its operation for the last file, <code>paste</code> will output a newline
character and move on to the next line.</p>
<h3><code>cat</code></h3>
<p><code>cat</code> is a standard Unix utility that reads files sequentially, writing them to standard output.
The name is derived from its function to con<code>cat</code>enate files.</p>
<h4>Examples</h4>
<p><pre>
paste file1.txt file2.txt <br>
cat fail1.txt fail2.txt</pre></p>
<h3>flags</h3>
<ul>
<li><code>-d</code> delimiters, which specifies a list of delimiters to be used instead of tabs
for separating consecutive values on a single line. Each delimiter is used in turn;
when the list has been exhausted, paste begins again at the first delimiter.
<h4>Examples</h4>
<pre>
paste -d "|" file1.txt file2.txt
paste -d "|," file1.txt file2.txt</pre></li>
<li><code>-s</code>, which causes paste to append the data in serial rather than in parallel;
that is, in a horizontal rather than vertical fashion.
<h4>Examples</h4>
<pre>
paste -s file1.txt file2.txt</pre></li>
<li><code>-u</code> is one option flag, <code>-u</code> for unbuffered output,
meaning that each byte is written after it has been read.
<h4>Examples</h4>
<pre>
cat -u file1.txt file2.txt</pre></li>
<li><code>-n</code> this option numbers all output lines
<h4>Examples</h4>
<pre>
cat -n file1.txt
cat -n file1.txt file2.txt</pre></li>
</ul>