This question already has an answer here:
- Is it possible to escape regex metacharacters reliably with sed 2 answers
In a file x
, a line containing 4*4 4*1 4*4 4*0
is to be replaced by 4*4 4*1 3*4 1*4 4*0
which is in file y
. I'm using the following code:
#!/bin/bash
old=`grep "4*4" x`;
new=`grep "4*4" y`;
sed -i "s/${old}/${new}/g" x
but it yields no change at all in x
. I'm a novice and this might be a silly question for this site but I'm unable to replace this expression with multiple special characters with another expression.