If you are using a newer version of sed, you can use -i to read and write to the same file. Using -i , you can specify the file extension so that a backup is made if something goes wrong. Also you do not need to use the -e flag unless you use multiple commands
sed -i.bak "s/${line}/${rep}/g" /root/new_scripts/a.conf
I just noticed that since the variables you use are quotes, you can use single quotes around your sed expression. In addition, your line contains a slash to avoid errors, you can use a different delimiter in the sed command (the delimiter should not be a slash):
sed -i.bak 's|${line}|${rep}|g' /root/new_scripts/a.conf
source share