What is branch in sed

Dan Track dan.track at gmail.com
Wed Aug 23 12:33:19 UTC 2006


On 8/23/06, Cameron Simpson <cs at zip.com.au> wrote:
> On 23Aug2006 11:52, Dan Track <dan.track at gmail.com> wrote:
> | I've searched and read documents on branching in sed (b) but I still
> | can't get my head round it.
> |
> | Could someone please explain to me how branching works, an example
> | would be nice.
>
> It's like goto. Here's an infinite loop:
>
>         :foo
>         b foo
>
> Cheers,
> --

Hi,

Thanks for the info. With that in mind I have the following example
I'm having trouble unerstanding. Would you be able to help me out with
understanding it? What does the $b in context to the whole file and
executing the lines of code on the file. Also what does $!N mean? And
do I really need P;D?


sed -e '$b
/^Target\[[^]]*\][.0-9]*:.*@[0-9.]*$/ {
$!N
s/^\(Target\[[^]]*\][.0-9]*:.*@\)[0-9.]*\nDirectory\[[^]]*\]:
\(.*\)$/\1\2.example.com/
P;D
}' text_files/mrtg.cfg > text_files/mrtg.cfg.changed

Thanks for your help

Dan




More information about the fedora-list mailing list