I have 2 files:
File_1.txt:
John Mary Harry Bill
File_2.txt:
My name is ID, and I am on line NR of file 1.
I want to create four files that look like this:
Output_file_1.txt:
My name is John, and I am on line 1 of file 1.
Output_file_2.txt:
My name is Mary, and I am on line 2 of file 1.
Output_file_3.txt:
My name is Harry, and I am on line 3 of file 1.
Output_file_4.txt:
My name is Bill, and I am on line 4 of file 1.
Normally for this purpose I would use the following sed command:
for q in John Mary Harry Bill do sed 's/ID/'${q}'/g' File_2.txt > Output_file.txt done
But this will only replace the ID for the name and will not contain the nr line of File_1.txt. Unfortunately, my bash skills are not much more than that ... Any tips or suggestions for a team that includes both files 1 and 2? I need to include file 1, because in fact the files are much larger than in this example, but I think I can understand the rest of the code if I know how to do this with this, hopefully a simpler example ... Many thanks in advance!
Abdel source share