Paste is mainly used for processing text files. As all known,
stdin can also be treated as a file.
paste file1 file2 will give a result where each line contains corresponding lines of every operand file delimited by a tab. And to designate delimiter of your own, simply use a
-d option like this:
paste -d'/' file1 file2.
To do the trick of “paste” multiple files with similar names, apply wildcards like this:
To better illustrate its function, let’s look at an example:
a.txt the file contains:
b.txt is as follows:
And the command
paste -d ',' a.txt b.txt gives the result:
paste operation on one file sees each line as an atom manipulative unit. That is, taking each line as a single file.
There is also
-d option working just like what it is for in multiple-file circumstance.
And there is special usage under this circumstance. To get it across clearer, let’s look at another example:
A text file labeled
data.txt contains this:
paste -d',' - - < data.txt, the output is:
paste -d',' - - - < data.txt, we get this:
Look at and learn from the differences between these two commands and outputs, which are easily understandable enough.