-2

I have two files like:

file 1 :

a stringori to replace, this stringori comme again 
other stringori2 to replace, stringori2 commes again
...

file 2:

stringori newstring
stringori2  newstring2
...

I want to get the result:

a newstring to replace, this newstring comme again 
other newstring2 to replace, newstring2 commes again
0

I'm pretty sure this has been solved / answered umpteen times in these fora. How about

awk 'NR == FNR {T[$1] = $2; next} {for (t in T) gsub (t, T[t])} 1' file2 file1
    a newstring to replace, this newstring comme again 
    other newstring2 to replace, newstring2 commes again

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.