Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

replace question

7 views
Skip to first unread message

as...@yahoo.com

unread,
Feb 18, 2013, 10:16:11 PM2/18/13
to
I want to replace a variable in a shell script, like the following line:

export NAME=FOO_1 #bla bla

Change FOO_1 to BAR one.

I tried following, none is working the way I want.

1) sed -i s/NAME=[a-zA-Z]\w*$/NAME=BAR_1/ file

2) sed -i s/NAME=[a-zA-Z]\w*/NAME=BAR_1/ file



1) did not found match

2) it replaced FOO_1 to BAR_1OO_1

Thanks in advance

Tone

unread,
Feb 22, 2013, 9:55:00 PM2/22/13
to
On 2013-02-19, as...@yahoo.com <as...@yahoo.com> wrote:
> I want to replace a variable in a shell script, like the following line:
>
> export NAME=FOO_1 #bla bla
>
> Change FOO_1 to BAR one.
>
> I tried following, none is working the way I want.
>
> 1) sed -i s/NAME=[a-zA-Z]\w*$/NAME=BAR_1/ file
>
> Thanks in advance
try sed -i s/NAME=[a-zA-Z_0-9]*/NAME=BAR_1/ file

0 new messages