I'm new here and haven't posted much, I'll try to make this as clear as I can.
I want to perform a find and replace that involves three files: find.csv identifies lines containing strings. I want to replace the entire line with a line from replace.csv. The third file is the mainfile.csv, which contains about 1000 lines.
This is what I have so far, but I'm getting an error message:
sed "s/$(cat find.csv)/$(cat replace.csv)/" mainfile.csv > out.csv
sed: 1: "s/CHL_13_R4
DCK_09_R4 ...": unterminated substitute pattern
Here is what the contents of the files look like:
find.csv
CHL_13_R4
DCK_09_R4
DCK_10_R4
DCK_11_R4
DCK_13_R4
replace.csv
CHL_13_R12,CHL_13,R12,10/14/2014
DCK_09_R12,DCK_09,R12,10/14/2014
DCK_10_R32,DCK_10,R32,10/14/2014
DCK_11_R21,DCK_11,R21,10/14/2014
The mainfile contains entries as in replace.csv, but about 30 need to be updated. So, taking the first line as an example. The line in mainfile.csv that has 'CHL_13_R4' needs to be replaced with CHL_13_R12,CHL_13,R12,10/14/2014
Thanks for the help!
find.csv
than you do inreplace.csv
. – Wildcard May 03 '16 at 23:24