I have the file dir1.txt
that contains the names of the following directories:
2
3
4
Directory 2 contains files 2_1.txt and 2_2.txt
Directory 3 contains files 3_1.txt and 3_2.txt
Directory 4 contains files 4_1.txt and 4_2.txt
Each file contains two lines.
Then I have created the following nested loop:
#!/bin/bash
input="dir1.txt"
while IFS=read -r line
do
for j in "$line/*"
do sed -e '$s/$/\n/' $j
#cat $j; echo
done >> output.txt
done < "$input"
Basically, I want to have a blank line between the concatenated files. With the above loop, I am only getting a blank line between the last file content in dir 2 and the first file in dir 3, as well as last file content in dir 3 and first file in dir 4 but I also want a blank line between the concatenated content of the files in the same directory. I have tried with cat $j; echo (commented out above) but to no avail. Tried with a nested for loop, again - I am getting the same outcome. I think my logic is wrong.