I try to write a script that would replace each word of a file by another corresponding word according to a list file.
phylofile
(the file to be modified) is:
(((swallowtail,noctuid):90,pyraloid):74,crambine)
namefile
(the list of mappings from old to new words) is:
crambine orocrambus
swallowtail papilio
noctuid catocala
The output should be:
(((papilio,catocala):90,pyraloid):74,orocrambus)
I hope it is more clear like that
I wrote the following script:
echo -n "Enter the path to the file where names should be changed: "
read phylofile
echo -n "Enter the path to the file containing the string searched and the replacing string: "
read namefile
while read var
do
searchstring=`echo "$var"|awk -F= '{print $1}'`
replacestring=`echo "$var"|awk -F= '{print $2}'`
sed "s/$searchstring/$replacestring/g" $phylofile > outputfile
done < $namefile
I get an error message (French) meaning there is no regular expression in the sed command.
I would be really thankful if you could help