[PLUG] another bash question
Richard Kurth
rkurth at starband.net
Tue Aug 6 22:00:34 UTC 2002
Hello Russ,
I tried this
A=$(uname -n)
sed -e "s/ServerName localhost/ServerName $A/"httpd.conf > httpd.new
mv httpd.new httpd.conf
But it gave me an error message
sed: -e expression #1, char 57: Unknown option to 's'
this works
A=$(uname -n)
sed -e "/ServerName localhost/c\\
ServerName $A" httpd.conf > httpd.new
mv httpd.new httpd.conf
Tuesday, August 06, 2002, 2:19:16 PM, you wrote:
RJ> Why not:
RJ> A=$(uname -n)
RJ> sed -e "s/ServerName localhost/ServerName $A/" < httpd.conf
RJ> Notice that you also need an 's' command for sed (before the first slash).
RJ> As given, this will only replace the first instance of "ServerName
RJ> localhost" with "ServerName $A". If you want all instances replaced:
RJ> A=$(uname -n)
RJ> sed -e "s/ServerName localhost/ServerName $A/g" < httpd.conf
RJ> I'm not sure why your redirecting here... You don't need to.
RJ> A=$(uname -n)
RJ> sed -e "s/ServerName localhost/ServerName $A/" httpd.conf >httpd.conf.new
RJ> mv httpd.conf.new httpd.conf
RJ> Will do that I think you are wanting.
RJ> At 02:09 PM 8/6/2002 -0700, you wrote:
>>Ok I removed the backslash after $A so it looks like this
>>A=$(uname -n)
>> sed -e "/ServerName localhost/c\
>> ServerName $A
>> " < httpd.conf
>>
>> and I still get the
>> sed: -e expression #1, char 24: Extra characters after command
RJ> Russ Johnson
RJ> http://www.dimstar.net
RJ> Why aren't there any left-handed screwdrivers?
RJ> _______________________________________________
RJ> PLUG mailing list
RJ> PLUG at lists.pdxlinux.org
RJ> http://lists.pdxlinux.org/mailman/listinfo/plug
--
Best regards,
Richard mailto:rkurth at starband.net
More information about the PLUG
mailing list