When I run cat 1.txt 2.txt > result.txt
, I want result.txt
to have a linebreak between the end of the contents of 1.txt
and the beginning of the contents of 2.txt
. How do I do this?
Asked
Active
Viewed 102 times
0
-
possible duplicate of [Concatenating Files And Insert New Line In Between Files](http://stackoverflow.com/questions/8183191/concatenating-files-and-insert-new-line-in-between-files) – gsp8181 May 12 '15 at 14:08
-
possible duplicate of [How do I include a blank line between files I'm concatenating with "cat"?](http://stackoverflow.com/questions/1653063/how-do-i-include-a-blank-line-between-files-im-concatenating-with-cat) – fedorqui May 12 '15 at 14:11
1 Answers
2
One of many options is:
echo | cat 1.txt - 2.txt > result.txt
The - argument says 'accept standard input' and the echo provides the new line
This option only works cleanly for 2 files. If you are actually looking at many files etc then for example:
(cat 1.txt; echo; cat 2.txt; echo; cat 3.txt) > result.txt
Would work; It's worth noting this spawns more cat processes.

tolanj
- 3,651
- 16
- 30