I want to write a shell script to merge contents of multiple files in a given directories.
DIR1 contains sample1.txt sample2.txt
sample1.txt contents :---this is sample1 file
sample2.txt contents :---this is sample2 file
DIR2 contains demo1.txt demo2.txt
demo1.txt contents :---this is demo1 file
I tried :
(find /home/DIR1 /home/DIR2 -type f | xargs -i cat {} ) > /result/final.txt
It worked!
this is sample2 file this is sample1 file this is demo1 file
however output appears in a single line I need every file's output in a separate new line. like this:
this is sample1 file
this is sample2 file
this is demo1 file
how to achieve this?
Any help would be appreciated in advance.