Home > Archive > AWK > August 2005 > Sed replace doesn't work from shell script
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Sed replace doesn't work from shell script
|
|
| takarov2003@yahoo.com 2005-07-25, 10:03 pm |
| Please accept my apologies if this is not the right place to ask this
question, but it appears that google doesn't echo a group for sed.
my problem is that i have a file I wish to edit on pattern match,
replacing the matched line with another line.
from the command line I do:
teufel# sed '/#auth./c\
> auth replacement' /etc/syslog.conf > syslog.conf
This works fine from the command line. When I put these same lines in
a shell script, i get:
sed: command garbled: /#auth/c\
what am i missing here? substitution sed lines (one-liners) work fine
in the same script.
| |
| Bob Harris 2005-07-25, 10:03 pm |
| In article <1122327610.551790.326920@f14g2000cwb.googlegroups.com>,
takarov2003@yahoo.com wrote:
> Please accept my apologies if this is not the right place to ask this
> question, but it appears that google doesn't echo a group for sed.
>
> my problem is that i have a file I wish to edit on pattern match,
> replacing the matched line with another line.
>
> from the command line I do:
>
> teufel# sed '/#auth./c\
>
> This works fine from the command line. When I put these same lines in
> a shell script, i get:
>
> sed: command garbled: /#auth/c\
>
> what am i missing here? substitution sed lines (one-liners) work fine
> in the same script.
Do you have any trailing white space following the \ ???
Bob Harris
| |
| takarov2003@yahoo.com 2005-07-25, 10:03 pm |
|
Bob Harris wrote:
> In article <1122327610.551790.326920@f14g2000cwb.googlegroups.com>,
> takarov2003@yahoo.com wrote:
>
>
> Do you have any trailing white space following the \ ???
I have tried it with and without trailing spaces . . .
>
> Bob Harris
| |
| Chris F.A. Johnson 2005-07-26, 4:04 am |
| On 2005-07-25, takarov2003@yahoo.com wrote:
> Please accept my apologies if this is not the right place to ask this
> question, but it appears that google doesn't echo a group for sed.
>
> my problem is that i have a file I wish to edit on pattern match,
> replacing the matched line with another line.
>
> from the command line I do:
>
> teufel# sed '/#auth./c\
>
> This works fine from the command line. When I put these same lines in
> a shell script, i get:
>
> sed: command garbled: /#auth/c\
>
> what am i missing here? substitution sed lines (one-liners) work fine
> in the same script.
How are you creating the file? Is it on a MS platform which is
adding a carriage return to the line endings?
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
========================================
==========================
Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
<http://www.torfree.net/~chris/books/cfaj/ssr.html>
| |
| takarov2003@yahoo.com 2005-07-26, 9:00 am |
|
Chris F.A. Johnson wrote:
> On 2005-07-25, takarov2003@yahoo.com wrote:
>
> How are you creating the file? Is it on a MS platform which is
> adding a carriage return to the line endings?
>
friends don't let friends do windows. this file was created and
executed on the same Solaris 7 sparc system.
>
> --
> Chris F.A. Johnson <http://cfaj.freeshell.org>
> ========================================
==========================
> Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
> <http://www.torfree.net/~chris/books/cfaj/ssr.html>
| |
| Ed Morton 2005-07-26, 9:00 am |
| takarov2003@yahoo.com wrote:
> Please accept my apologies if this is not the right place to ask this
> question, but it appears that google doesn't echo a group for sed.
>
> my problem is that i have a file I wish to edit on pattern match,
> replacing the matched line with another line.
>
> from the command line I do:
>
> teufel# sed '/#auth./c\
>
>
>
> This works fine from the command line. When I put these same lines in
> a shell script, i get:
>
> sed: command garbled: /#auth/c\
>
> what am i missing here? substitution sed lines (one-liners) work fine
> in the same script.
>
It's not obvious what the problem is and since this is the wrong NG
anyway, I'm setting followups to comp.unix.shell (which you should use
in future for sed questions).
Ed.
| |
| John Savage 2005-08-03, 9:59 pm |
| takarov2003@yahoo.com writes:[color=darkred]
Your script works for me. But an alternative true one-liner is:
sed -e '/#auth./c' -e 'auth replacement' syslog
--
John Savage (my news address is not valid for email)
|
|
|
|
|