on my professional endeavors...
Bash commands to combine files

Bash commands to combine files

Suppose that you want to combine two (or more) files, containing for example a series of data. There are, actually, two ways to do it in bash:

$ paste temp1 temp2 > temp
which adds the contents of the two files horizontally, like columns, and

$ cat temp1 temp2 > temp
which adds the contents vertically, one after the other.

Simple as that.

2 Comments

  1. z)

    Good to know!
    You can also splice data when using “newline” as delimiter:

    $ cat file1
    1 2
    3 4

    $ cat file2
    a b
    c d

    $ paste –delimiter=”\n” file1 file2 > file3
    $ cat file3
    1 2
    a b
    3 4
    c d

Leave a Reply

Your email address will not be published. Required fields are marked *