Combine two text files
This page was last updated on October 15, 2009.
Side By Side
- Type this command in a terminal window to have the contents displayed side by side:
- Example:
paste file1 file2 > combinedfile
Contents of file1 | Contents of file2 | Contents of combinedfile |
1 2 3 4 5 = |
a b c = |
1 a 2 b 3 c 4 5 = = |
Row By Row
- Type this command in a terminal window to have the contents displayed in serial (the first through the last line of the first file followed by the first through last line of the second file):
- Example:
paste --serial file1 file2 > combinedfile
Contents of file1 | Contents of file2 | Contents of combinedfile |
1 2 3 4 5 = |
a b c = |
1 2 3 4 5 = a b c = |
Top To Bottom
- Type this command in a terminal window to have the contents displayed from top to bottom:
- Example:
cat file1 file2 > combinedfile
Contents of file1 | Contents of file2 | Contents of combinedfile |
1 2 3 4 5 = |
a b c = |
1 2 3 4 5 = a b c = |
Obligatory Happy Ending
And they all lived happily ever after. The end.
Comment: