0

I'd want to do this:

sed -i 's#cellname#$cell#g' file.txt

I meant to replace all "cellname" words with the value of variable $cell instead of "$cell" text.

ex: $cell = nand4

then after sed, file.txt will contains word "nand4" instead of "cellname"

fedorqui
  • 275,237
  • 103
  • 548
  • 598
  • 2
    I've found a solution to my question already. sed -i 's#cellname#'$cell'#g' file.txt – leelong2k4 May 08 '15 at 10:27
  • This is a way, since you are closing the quotes and then opening again. However, I would go for `sed -i "s#cellname#$cell#g" file.txt`. That is, using double quotes like the duplicate suggests. – fedorqui May 08 '15 at 10:41
  • And when you stick with your solution, put double quotes around $cell, so it will not break when the value of cell has a space: `sed -i 's#cellname#'"$cell"'#g' file.txt` – Walter A May 08 '15 at 13:57

0 Answers0