Using variables within sed
Clash Royale CLAN TAG #URR8PPP Using variables within sed I am trying to use a variable within sed but cant work it out. I have tried read -p " enter your name" name sed -i 's/myname/$name/g' file But unfortunately it just replaces myname with "$name". Is there an alternative way? have you tried with $name ? – Preuk Apr 27 '15 at 13:31 $name This should work! Do you use some type of exotic shell? – hek2mgl Apr 27 '15 at 13:35 that works great too, thank you – rog Apr 27 '15 at 13:48 possible duplicate of sed with & in variable – NeronLeVelu Apr 27 '15 at 14:02 possible duplicate of sed substitution with bash variables – Etan Reisner Apr 27 '15 at 14:43 1 Answer 1 The problem is that the bash shell does not do variable expansion within single quotes. For example: bash pax> name=paxdiablo pax> echo 'Hello, $name, how are you?' Hello, $name, how are you? For simple cases like t...