[PLUG] another bash question

Richard Kurth rkurth at starband.net
Tue Aug 6 20:10:58 UTC 2002


Hello Shannon,

Tuesday, August 06, 2002, 12:42:41 PM, you wrote:


SCD> On Tue, 6 Aug 2002, Richard Kurth wrote:

>>
>> Will this work in bash
>>
>> A='uname -n'   #or this A=$(uname -n)
>> sed -e '/ServerName localhost/c\
>> ServerName $A\
>> ' < httpd.conf
>>
>> So far all it does is just fill in the ServerName with an $A
>> it seams like the problem is that the variable is not read inside the
>> sed command how can I make this work

SCD> Use double quotes around the string on your sed command line, single
SCD> quotes suppress interpretation of the $A and pass it as part of the
SCD> string literal.

I changed it to look like this
A=$(uname -n)
sed -e '/ServerName localhost/c\
ServerName "$A"\   #<-I added the double quotes
' < httpd.conf

And this is what it looks like when it writes to the httpd.conf file
ServerName "$A"
It is not filling in the variable with what is in the variable.


-- 
Best regards,
 Richard                            mailto:rkurth at starband.net





More information about the PLUG mailing list