Combining text files as columns

To combine two (or more) text files as individual columns in the same file, such as:

file1:

[code]foo
foo1
foo2
foo3[/code]

file2:

[code]foobar
foobar1
foobar2
foobar3[/code]

into:

[code]foo foobar
foo1 foobar1
foo2 foobar2
foo3 foobar3[/code]

rather than using an ugly combination of sed and awk, you can use the `paste’ command:

[code lang=”bash”]paste file1 file2[/code]

Leave a Reply