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

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



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


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