The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 -->
  #2 (permalink)  
Old 01-03-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by figaro View Post
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?

First, don't use the -i option to sed without giving a backup extension, especially when you are having problems with it.

Second, there is nothing wrong with your sed command (unless you are using a sed which doesn't support -i or a *BSD sed which requires a backup extension with -i).