This is probably best done if one sed script converts the mapping file into a second sed script, which is then applied to the data being converted. Since you say bash , I assume you have a process replacement . If you do not, either upgrade bash , or use temporary files.
sed -i .bak -f <(sed 's%^ *\([^ ,]\{1,\}\), *\([^ ]\{1,\}\) *$%s/\1/\2/g%' \ control-file) \ datefile-1 datafile-2 ...
The regular expression is rather complicated because the control data shown in the question has leading spaces and possibly trailing spaces and have a comma as a field separator. This data in the control file was formatted more orthodoxly:
bird,snake tree,bush river,stream
the code could be simpler:
sed -i .bak -f <(sed 's%\([^,]*\),\(.*\)%s/\1/\2/g%' control-file) \ datefile-1 datafile-2 ...
source share