Você pode fazer isso usando bash
arrays associativos.
$ cat foo.txt # Contents of "foo.txt"
ABC,23
DFG,45
Ghj,678
$ cat bar.txt # Contents of "bar.txt"
Listed LinkedIn yellow ABC
Fixed DFG linked ABC
Holiday Europe Ghj DFG
$ declare -A foobar # Declaring associative array "foobar"
## Putting comma separated portions of file "foo.txt" as key-value
## pair for array "foobar"
$ while IFS=',' read a b; do foobar["$a"]="$b"; done <foo.txt
## Now reading each line of "bar.txt" and iterating over the keys
## of array "foobar" by "${!foobar[@]}" to find a match, if found
## correspoding value of the key will replace the key using parameter
## expansion pattern "${line//key/value}"
$ while IFS=' ' read line; do for i in "${!foobar[@]}"; do \
line="${line//"$i"/"${foobar["$i"]}"}"; done; echo "$line"; done <bar.txt
Listed LinkedIn yellow 23
Fixed 45 linked 23
Holiday Europe 678 45
Aqui está a versão expandida da última parte:
while IFS=' ' read line; do
for i in "${!foobar[@]}"; do
line="${line//"$i"/"${foobar["$i"]}"}"
done
echo "$line"
done <bar.txt