#Answer#
Answer
If you are not concerned about speed (this is a one time task), then maybe you could try this:
cat map.txt | while read line; do
neww=${line##* };
oldw=${line%% *};
find /some/folder -type f -exec sed -i "s/$oldw/$neww/g" {} \;
done
Not optimal, I know... :-P
PS: check in a test folder to see if it works!
#Explanation#
Explanation
Basically:
- Cat file map.txt.
- Read each line and get the word to be replaced
$oldwand the replacement$neww. - For each pair, execute the find command you were already using (notice the double quotes this time in order to allow variable substitution).
#About parameter expansion#
About parameter expansion
In order to set the variables $oldw and $neww we have to get the first and last word of each line. For doing so, we are using parameter expansion (pure Bash implementation), although we could have used other ways to get the first and last word of the string (i.e. cut or awk).
${line##* }: from variableline, remove largest prefix (double#) pattern, where pattern is any characters (*) followed by a space (). So we get the last word inline.${line%% *}: from variableline, remove largest suffix (double%) pattern, where pattern is a space () followed by any characters (*). So we get the first word inline.
Words were separated by a space in this case, but we could have used any separator.