sed replace issue
am 15.10.2007 15:03:27 von peter sands
Hi,
I have a problem with sed. I am trying to replace all occurances of
the same field in many files , the field I am having problems is :
containermax=1000
Now the containermax value may well be 0 in some files or 2400 or 159
in others.
I need to reset all the values back to 0
For instance if the value on the field was 2400, when I run the
following
I get weird results
$ sed s/containermax=[0..9]*/containermax=0/g contain.mbf
containermax=24000
If should be:
containermax=0
Where am I going wrong,
thanks
Pete
Re: sed replace issue
am 15.10.2007 15:07:55 von Ed Morton
peter sands wrote:
> Hi,
> I have a problem with sed. I am trying to replace all occurances of
> the same field in many files , the field I am having problems is :
>
> containermax=1000
>
> Now the containermax value may well be 0 in some files or 2400 or 159
> in others.
>
> I need to reset all the values back to 0
>
> For instance if the value on the field was 2400, when I run the
> following
> I get weird results
> $ sed s/containermax=[0..9]*/containermax=0/g contain.mbf
> containermax=24000
>
> If should be:
> containermax=0
>
> Where am I going wrong,
> thanks
> Pete
>
sed 's/containermax=[0-9]*/containermax=0/g' contain.mbf
Regards,
Ed.
Re: sed replace issue
am 16.10.2007 14:10:57 von Maxwell Lol
peter sands writes:
> I get weird results
> $ sed s/containermax=[0..9]*/containermax=0/g contain.mbf
> Where am I going wrong,
A tip to explain strange things - put "echo" in front of your command to see if the shell
is modifying arguments before passing it to your command
i.e.
$ echo sed s/containermax=[0..9]*/containermax=0/g
Re: sed replace issue
am 19.10.2007 13:05:09 von martin
On 2007-10-15, peter sands wrote:
> Hi,
> I have a problem with sed. I am trying to replace all occurances of
> the same field in many files , the field I am having problems is :
>
> containermax=1000
>
> Now the containermax value may well be 0 in some files or 2400 or 159
> in others.
>
> I need to reset all the values back to 0
>
> For instance if the value on the field was 2400, when I run the
> following
> I get weird results
> $ sed s/containermax=[0..9]*/containermax=0/g contain.mbf
> containermax=24000
>
> If should be:
> containermax=0
>
try
sed -i 's/containermax=[0..9]*/containermax=0/g' contain.mbf
--
Martin Lefebvre
WWW: http://www.sekurity.com
"This is my Linux box. There are many like it, but this one is mine.
My Linux box is my best friend. It is my life."