cat file1 file2
will combine two text files. But if I want to add some separator between, like a line or two of ********************************
, do I have to open the first file, and add the line at its end, or open the second file and add the line at its top, and then run the cat
command? Can it be done with just running a command?
Combine two text files with adding some separator between
text processing
Best Answer
In
bash
andzsh
you can do:or as mikeserv indicated in his comment (in any shell):
and in Bash as David Z commented:
Any newlines in the files will be shown. If you don't want a newline after the "separator" (e.g. in case
file2
starts with a newline) you can useecho -n '****'
, so suppress the newline after the*
.