[PLUG] Help with bash script
Richard Kurth
rkurth at starband.net
Tue Aug 6 18:22:07 UTC 2002
Hello Richard,
I figured it out thanks to every body
Tuesday, August 06, 2002, 11:05:29 AM, you wrote:
RK> Hello Don,
RK> Tuesday, August 06, 2002, 9:30:29 AM, you wrote:
DB>> Richard Kurth wrote:
>>>
>>> I need some help with a bash script. I need to read a file and find a
>>> certain line in that file and then add two lines directly after that
>>> line.
>>> example
>>> I need to search the file and find this line. The file is a httpd.conf file
>>> RewriteRule ^/cgi-bin/test/(.+) proto://servername:81/cgi-bin/test/$1 [L,R]
>>>
>>> and then add two lines right below it.
>>>
>>>
DB>> Use the sed "a" command.
DB>> sed -e '/reg-exp_pattern/a\ # Address/pattern to match, and "a" command
DB>> line(s) of\ # (the backslash after the "a" is req'd.)
DB>> new text to\ # Backslashes are required after all but
DB>> add # the last line of new text.
DB>> ' # (Don't forget the last single quote mark!)
DB>> sed -e '/RewriteRule .*cgi-bin\/test.* proto:\/\/servername:81.*/a\
DB>> new_line#1\
DB>> new_line#2
DB>> ' < httpd.conf
DB>> I got a bit lazy on the reg-exp expression for matching -- you can
DB>> tighten it if necessary.
DB>> - Don
RK> This is what I am trying to write to the httpd.conf file a little more
RK> elaborate than what I first sead in my e-mail
RK> I keep getting this when I run the script
RK> sed: -e expression #1, char 233: Unknown command: ``R''
RK> so I figure that it is reading the first R in the first line I am
RK> trying to write and interpreting it as a command. Is there a way to
RK> make it understand that those 6 lines are to be written and not read
RK> sed -e '/RewriteRule .*cgi-bin\/.cobalt.* proto:\/\/servername:81.*/a\
RK> RewriteCond %{HTTP_HOST} ^([^:]+)
RK> RewriteRule ^/acp/?$ proto://servername:800/autocontrol/index.php
RK> RewriteCond %{HTTP_HOST} ^([^:]+)
RK> RewriteRule ^/ucp/?$ proto://servername:800/user/index.php
RK> RewriteCond %{HTTP_HOST} ^([^:]+)
RK> RewriteRule ^/rcp/?$ proto://servername:800/resellerpanel/index.php
RK> ' < httpd.conf
--
Best regards,
Richard mailto:rkurth at starband.net
More information about the PLUG
mailing list