I'm trying to make work a sed command inside of a shell script that takes variables while interacting with the user, but I can not make it work because of the backreference I use in it.... some help...?
Script:
echo "Origin language?\n"
read ol
echo "\nTarget language?\n"
read tl
echo "\ntmx file name?\n"
read file
then at the sed command I have tried these ways:
1.
sed -r "s/lang=\"$ol\">(.*)$/\1/g" "$file" > ${file}_${ol}.txt
sed -r "s/lang=\"$tl\">(.*)$/\1/g" "$file" > ${file}_${tl}.txt
2.
thisol = "<tuv xml:lang=\"$ol\">(.*)$"
thistl = "<tuv xml:lang=\"$tl\">(.*)$"
sed -r "s/$thisol/\1/g" "$file" > ${file}_${ol}.txt
sed -r "s/$thistg/\1/g" "$file" > ${file}_${tl}.txt
3.
thisol = "<tuv xml:lang=\"$ol\">(.*)$"
thistl = "<tuv xml:lang=\"$tl\">(.*)$"
that = "\\\1"
sed -r "s/$thisol/$that/g" "$file" > ${file}_${ol}.txt
sed -r "s/$thistg/$that/g" "$file" > ${file}_${tl}.txt