Re: sed and quoting issue



On Aug 11, 4:33 pm, Janis Papanagnou <janis_papanag...@xxxxxxxxxxx>
wrote:
trighole schrieb:



On Aug 11, 2:38 pm, Ed Morton <mortons...@xxxxxxxxx> wrote:
On 8/11/2010 7:08 AM, trighole wrote:

Hello,
I'd like to execute it:
sed -e "s#\(^\.INCLUDE[ \t]*\"\).*\(noMisMatch\)#\1$MODEL_DIR\2#g"
totoFile> titiFile
The problem is coming from \" which generate an error.
What error? Copy/paste what you get when you execute the script.

The first pattern i would like to catch is: .INCLUDE " which is in
regexp \(^\.INCLUDE[ \t]*\"\), but " is generated problem with sed
if i use single quote like this
sed -e 's#\(^\.INCLUDE[ \t]*\"\).*\(noMisMatch\)#\1${MODEL_DIR}\2#g'
totoFile> titiFile
I do not have problem to catch " but the $MODEL_DIR is not substitute
by the righ value.
can yoiu help me.
What you posted looks fine and works for me:

$ MODEL_DIR=abc
$ cat file
.INCLUDE " bar noMisMatch
$ sed -e "s#\(^\.INCLUDE[ \t]*\"\).*\(noMisMatch\)#\1$MODEL_DIR\2#g" file
.INCLUDE "abcnoMisMatch

Regards,

Ed.

I am in csh, and you seem in sh, perhaps that is why it is not working

So you seem to have found the solution yourself; first type sh then type
your sed command.

Janis

I'd prefer to exut this sed in CSH, as it is in a csh script and
embeded in a loop, it could slow the process to switch from csh to sh
multiple times

fab
.



Relevant Pages

  • Re: sed and quoting issue
    ... I'd like to execute it: ... totoFile> titiFile ... if i use single quote like this ...
    (comp.unix.shell)
  • Re: sed and quoting issue
    ... I'd like to execute it: ... totoFile> titiFile ... if i use single quote like this ...
    (comp.unix.shell)
  • Re: sed and quoting issue
    ... totoFile> titiFile ... Copy/paste what you get when you execute the script. ... if i use single quote like this ...
    (comp.unix.shell)
  • sed and quoting issue
    ... I'd like to execute it: ... totoFile> titiFile ... The first pattern i would like to catch is: ...
    (comp.unix.shell)