0

This question already has an answer here:

I want to combine multiple text files in a directory to a new file while leaving new lines between files.

marked as duplicate by don_crissti, αғsнιη, Jeff Schaller, Isaac, Rui F Ribeiro Sep 9 '18 at 20:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

Depending on the situation, it could be as easy as:

some globbing to grab your files (filea, fileb, filec, etc.)

FILES=`ls file*`

then concatenate them

for i in $FILES; do cat "${i}" >> newfile; echo "" >> newfile; done
0

One way to do it is with GNU find:

td=$(mktemp -d);printf '\n\n' > "$td/2"
find . -maxdepth 1 -type f -exec cat {} "$td/2" \; | head -n -2 > "$td/log"

find gets the regular files in the current directory and passes them to cat which also has the empty lines file concatenated.Finally the output is given to head which deletes the trailing empty lines and then stored in the log file.

perl -lpe '$\ = eof && !eof() ? "\n\n" : $/' *.files

Not the answer you're looking for? Browse other questions tagged or ask your own question.