Re: What is branch in sed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/23/06, Paul Howarth <paul@xxxxxxxxxxxx> wrote:
Dan Track wrote:
> On 8/23/06, Cameron Simpson <cs@xxxxxxxxxx> wrote:
>> On 23Aug2006 11:52, Dan Track <dan.track@xxxxxxxxx> 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

The sed script quoted is heavily based on an example in the "sed FAQ"
(http://sed.sourceforge.net/sedfaq4.html#s4.23.2); reading that document
  is quite useful for people learning sed I think.

Paul.


Hi Paul,

Thanks for the info. As a small query I'm kind of understanding what b
means, but what does "$b" mean and how does it affect the script. I
thought what preceded b was the matching clause which dictates when a
jump should be performed. So how does the "$" come into play?

Thanks
Dan

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux