You could also use perl, which should support \b on all platforms. Assuming your list of replacements is in the format you show (separated by ->), you could do:
perl -F"->" -ane 'chomp;$rep{$F[0]}=${$F[1]};
END{open(A,"file");
while(<A>){
s/\b$_\b/$rep{$_}/g for keys(%rep);
print
}
}' replacements
###Explanation
The
-amakes perl run like awk, automatically splitting fields into the array@Fso$F[0]is the 1st field,$F[1]the second etc. The-Fsets the input field separator, just like-Fin awk. The-nmeans "read the input file, line by line and apply the script given by-eto each line".chomp: removes newlines (\n) from the end of the line.$rep{$F[0]}=${$F[1]};: this populates the hash%repmaking the pattern to be replaced (the first field,$F[0]) the key and the replacement ($F[1]) the value. *END{}: this is executed after the input file (replacements) has been read.open(A,"file"): open the filefilefor reading with filehandleA.while (<A>): read the file line by line.s/// for keys(%rep): this will iterate through all the keys of the%rephash, saving each key as the special variable$_. Thes///is the substitution operator and is making the same substitution as explained in Michael's answerMichael's answer.
You could also read through the file and use sed as shown in the other answers:
$ sed 's/->/\t/' replacements |
while IFS=$'\t' read from to; do sed -i "s/\b$from\b/$to/g" file; done