help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sed with Variable Substitution in the command


From: Steve Matzura
Subject: sed with Variable Substitution in the command
Date: Thu, 19 Sep 2024 10:03:01 -0400
User-agent: Mozilla Thunderbird Beta

Can't get any of these to work, despite reading and looking at several examples. Variable substitution has always been a problem for me because there doesn't seem to be a single hard-and-fast rule--sometimes the variable is quoted, sometimes it's wrapped in braces, sometimes the "$" is interpreted by the shell as a string positional directive ("$", "%"). All of the following fail:


sed -i 's/replace-this/$with_this_variable/'


sed -i 's/replace-this/${with_this_variable}/'


sed -i 's/replace-this/"${with_this_variable}/'


What am I missing?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]