From: trighole on
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.
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.

regards,

fabrice
From: Ed Morton on
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.
From: trighole on
On Aug 11, 2:38 pm, Ed Morton <mortons...(a)gmail.com> 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
From: Janis Papanagnou on
trighole schrieb:
> On Aug 11, 2:38 pm, Ed Morton <mortons...(a)gmail.com> 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
From: trighole on
On Aug 11, 4:33 pm, Janis Papanagnou <janis_papanag...(a)hotmail.com>
wrote:
> trighole schrieb:
>
>
>
> > On Aug 11, 2:38 pm, Ed Morton <mortons...(a)gmail.com> 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