Re: [OT] sed command to add line after matching lines

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

 



Dan Track wrote:
... I want to add a few lines after matching a couple of lines in a
file using sed, ...

sed can be awkward when working with more than one line at a time.

Can you use perl?

$ perl -pe 'BEGIN{undef $/};s/server 10.33.45.3\nserver ldap.example.com\nserver orion/# server 10.33.45.3\n# server ldap.example.com\n# server orion\n\nserver fire.example.com\nserver earth.example.com\nserver space.example.com\n/s' <test.conf

(That's meant to be all on one line.)

<Joe

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux