The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




Thread: Sed problem
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 01-03-2009
figaro figaro is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 268
Sed problem

When installing apache22, in the file httpd.conf the following line

Code:
#ServerName www.example.com:80

needs to be replaced commonly by

Code:
ServerName localhost:80

I tried using the following

Code:
sed -i 's/#ServerName www.example.com:80/ServerName localhost:80/' /usr/local/etc/apache22/httpd.conf

but the error message was:

Code:
sed: 1: "/usr/local/etc/apache22 ...": extra characters at the end of l command

and the substitution was not made. What is the correct sed command to achieve the substitution?

EDIT: This probably has to do with the "#" at the start of the line as the man page states:
Quote:
The ``#'' and the remainder of the line are ignored (treated as a
comment), with the single exception that if the first two charac-
ters in the file are ``#n'', the default output is suppressed.
This is the same as specifying the -n option on the command line.
It would still be useful to know how to solve this problem.

Last edited by figaro; 01-03-2009 at 05:03 PM..