Previous Section  < Day Day Up >  Next Section

paste—merges same lines of several files or subsequent lines of one file


paste filename1 filename2...

paste –d list filename1 filename2...

paste –s [ –d list ] filename1 filename2...


paste concatenates corresponding lines of the given input files filename1, filename2, and so on. It treats each file as a column or columns of a table and pastes them together horizontally (see cut).

Example A.40.

1   ls | paste - - -

2   paste -s -d"\t\n" testfile1 testfile2

3   paste file1 file2


EXPLANATION

  1. Files are listed in three columns and glued together with a tab.

  2. Combines a pair of lines into a single line using a tab and newline as the delimiter (i.e., the first pair of lines are glued with a tab; the next pair are glued by a newline, the next pair by a tab, etc.). The –s switch causes subsequent lines from testfile1 to be pasted first and then subsequent lines from testfile2.

  3. A line from file1 is pasted to a line from file2, glued together by a tab so that the file lines appear as two columns.

    Previous Section  < Day Day Up >  Next Section