5
I have a file which has (many) strings I'd like to replace, so I thought about using a simple command like:
sed 's/string1/string2/g' file1 > out
However, there are too many strings for that to be repeated manually. So I made a list of all the strings to be replaced, each in a line, and named it file A. Then I made a list of all the replacement strings, and named it file B.
Is there a way to do something like:
sed 's/line i of file A/line i of file B/g' file1 > out
for each line of file A?
1NIce, this worked! just in my case I needed to use double quotes (
"s/$n/$k/g"
instead of's/$n/$k/g'
)Also, if it helps anybody I'd name the files like this:
fileA --> replace_what
fileB --> replace_with
file1 --> file_to_process
^^ – aesede – 2015-07-01T21:19:40.520
+1, this answer is simpler than mine and doesn't require subshell. – Nykakin – 2013-01-12T01:38:50.487