sed puzzle
Charles Jones
charles.jones at ciscolearning.org
Wed Dec 5 10:25:30 MST 2007
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 field).
-Charles
Nathan Aubrey wrote:
> 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
> there, but if I try to swap out a kids name and there is no kids name already
> in place, how do I add it instead? Is it one command, or must I test if the
> content is empty then add instead of replacing?
>
> The field example cannot change as it's just the format I use...
> I appreciate any insite, sed is a great tool, but man! what a beast!
>
>
>
More information about the PLUG-discuss
mailing list