I want to cat all the files in a directory, but include some spacer between each one.
The cat Command In this case, the cat command will read from the terminal and appends the data to the file. txt. This will add two lines to the end of file. txt.
Type the cat command followed by the file or files you want to add to the end of an existing file. Then, type two output redirection symbols ( >> ) followed by the name of the existing file you want to add to.
You can use cat with redirection to append a file to another file. You do this by using the append redirection symbol, ``>>''. To append one file to the end of another, type cat, the file you want to append, then >>, then the file you want to append to, and press <Enter>.
use awk
awk 'FNR==1{print ""}{print}' file* > out.txt
Try
find . -type f -exec cat {} \; -exec echo "-- spacer --" \;
Obviously, the 'spacer' can be more than the simple example used here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With