I want to use the sed command (or something that works) to replace a word in a template file with a word in a line of another file.
As an example I have a file with a list of words, each word is in a different line and I want to use sed to take the first word (which is in the first line) and put it in another file where the word "value1" is written. I thought that with this post I could be able to do it, but I can't figure it out.
Graphic example:
File A:
Maria
Albert
Toni
Henry
Tom
File B:
The name of the student is: value1
Expected output for line 3:
The name of the student is: Toni
I want to be able to move one of the names from file A to file B where value1 is placed. And I want to do it multiple times.
value1
always occur one and only one time in the template? – Stéphane Chazelas Apr 18 '18 at 09:37value2
,value3
... ? How are the corresponding entries stored in fileA? – Stéphane Chazelas Apr 18 '18 at 09:43value1, value2 and value3
be distributed along 5 input lines? – RomanPerekhrest Apr 18 '18 at 10:11value
s and lines. I still don't understand whyvalue1
is douns on line 3. – Philippos Apr 18 '18 at 11:45printf
formats instead of your own format? Example' The name of the student is %s'
, then you would not need to do the search and replace of value1 which @Stéphane Chazelas does in his perl script. – Raphael Ahrens Apr 20 '18 at 06:36