bash cat multiple files bash cat multiple files linux linux

bash cat multiple files


cat f1 <(echo) f2 <(echo) f3 <(echo) 

or

perl -pe 'eof&&s/$/\n/' a b c


As soon as you cat the files, there will be no EOF in between them, and no other way to find the border, so I'd suggest something like for file in f1 f2 f3; do cat $file; echo; done or, with indentation,

for file in f1 f2 f3; do    cat $file;    echo;done


EOF isn't a character, not even CTRL-D - that's just the usual terminal method for indicating EOF on interactive input. So you can't use tools for translating characters to somehow modify it.

For this simple case, the easiest way is to stop worrying about trying to do it in a single cat :-)

cat f1; echo; cat f2; echo; cat f3

will do the trick just fine. Any larger number of files may be worthy of a script but I can't see the necessity for this small case.

If you want to combine all those streams for further processing, simply run them in a subshell:

( cat f1; echo; cat f2; echo; cat f3 ) | some_process