From: peter sands on 15 Oct 2007 09:03 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
From: Ed Morton on 15 Oct 2007 09:07 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.
From: Maxwell Lol on 16 Oct 2007 08:10 peter sands <peter_sands(a)techemail.com> 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
From: martin on 19 Oct 2007 07:05 On 2007-10-15, peter sands <peter_sands(a)techemail.com> 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 <dadexter_at_nospam_sekurity_dot_com> 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."
|
Pages: 1 Prev: sed/awk insert - help gurus Next: HELP: rsync using destination enviorment data |