I read the value of the variable I want to change (a) and then I read the new value of it (b).
#!/bin/bash
read a
read b
sed 's/$a/$b/' file.txt
file.txt contains only numbers
This is the code and it doesn't make the substitute.
I read the value of the variable I want to change (a) and then I read the new value of it (b).
#!/bin/bash
read a
read b
sed 's/$a/$b/' file.txt
file.txt contains only numbers
This is the code and it doesn't make the substitute.
You should use double quote, instead of single quote: single quote prevents variable expansion:
sed "s/$a/$b/" file.txt