sed puzzle

2007-12-05 Thread Nathan Aubrey
All, I need to replace some words with other words, but sometimes the words are not present, so I need to add the words. In a config file I use, it has the following field KIDS : Mother : Amanda Father : Scott It is easy to swap out the names of mother or father, as the variables are

Re: sed puzzle

2007-12-05 Thread reed
On Wed, 5 Dec 2007, Nathan Aubrey wrote: > I need to replace some words with other words, but sometimes the words > are not present, so I need to add the words. > In a config file I use, it has the following field > > KIDS : > Mother : Amanda > Father : Scott > > > It is easy to swap o

Re: sed puzzle

2007-12-05 Thread Charles Jones
What about something like: $ cat file KIDS: Mother : Amanda Father : Scott $ cat file | sed 's/:.*/: bob/g' KIDS: bob Mother : bob Father : bob Not sure what you are trying to do, but the point is that using .* is probably what you want (it matches even if there is nothing in the fi

Re: sed puzzle

2007-12-05 Thread Nathan Aubrey
On Wednesday 05 December 2007 10:25:30 you wrote: > What about something like: > > $ cat file > KIDS: > Mother : Amanda > Father : Scott > > $ cat file | sed 's/:.*/: bob/g' > KIDS: bob > Mother : bob > Father : bob > > Not sure what you are trying to do, but the point is that using .*

Re: sed puzzle

2007-12-05 Thread Nathan Aubrey
On Wednesday 05 December 2007 10:31:50 you wrote: > On Wed, 5 Dec 2007, Nathan Aubrey wrote: > > I need to replace some words with other words, but sometimes the words > > are not present, so I need to add the words. > > In a config file I use, it has the following field > > > > KIDS : > > Moth

Re: sed puzzle

2007-12-05 Thread der.hans
Am 05. Dec, 2007 schwätzte Nathan Aubrey so: moin moin, I need to replace some words with other words, but sometimes the words are not present, so I need to add the words. In a config file I use, it has the following field KIDS : Mother : Amanda Father : Scott $ ( newkid=anke; oldmom