I am trying to interweave two files that contain one sentence per line. I double spaced (sed G) the first file and I would like to incorporate the content of the second file into those empty lines.
How can I interweave both files so that the 1st line of file B goes below the 1st line in file A, the 2nd line of file B below the 2nd line of file A, until it reaches the end ?
Example: [line number|sentence number|sentence]
1 1 fileA
2
3 2 fileA
4
5 3 fileA
6
7 4 fileA
Expected result:
1 1 fileA
2 1 FILEB
3 2 fileA
4 2 FILEB
5 3 fileA
6 3 FILEB
7 4 fileA
This is for a bash script: can it be done with sed or awk?
This might work for you (GNU sed):
You don’t need to double space the file first.
If you want to replace the empty lines though: