[talk] insert line after matched pattern (fwd)

Isaac (.ike) Levy ike at blackskyresearch.net
Wed Aug 19 12:50:22 EDT 2015


Fun!  I'll also add:

# after your pattern match, inserting on a new line:
# sed '/pattern/a \
line to insert after line with pattern\
' file

# before your pattern match, inserting on a new line:
$ sed '/pattern/a \
line to insert after line with pattern\
' file

--
Notable fun,

Infamous sed1line.txt and awk1line.txt docs, (can be found all over the net),
http://blackskyresearch.net/sed1line.txt
http://blackskyresearch.net/awk1line.txt

Best,
.ike



> On Aug 19, 2015, at 12:05 PM, Franco Fichtner <franco at opnsense.org> wrote:
> 
> Hi,
> 
> I had a similar issue once, maybe this code snippet
> can help you (basically going the route of an extra file
> with multiple lines):
> 
> https://github.com/opnsense/tools/blob/544cb95fda/build/core.sh#L78-L79
> 
> Not a beauty and not in production code anymore, but it
> did work.  :)
> 
> 
> Cheers,
> Franco
> 
>> On 19 Aug 2015, at 17:59, freebsd at fongaboo.com wrote:
>> 
>> 
>> Anyone know how to insert a line after a matched pattern using sed, awk or any other method that gets the job done? Any tutorials I find seem not to work in BSD due to GNU sed vs. non-GNU?
>> 
>> -------------------------------------------------------------------------
>> shot through the heart              ooh baby do you know what that's worth
>> and you're to blame                         ooh heaven is a place on earth
>> darling you give love                  they say in heaven love comes first
>> a bad name                              we'll make heaven a place on earth
>> ORBITAL                                                     "Halcyon Live"
>> 
>> _______________________________________________
>> CDBUG-talk mailing list
>> CDBUG-talk at lists.nycbug.org
>> http://lists.nycbug.org/mailman/listinfo/cdbug-talk
>> 
>> _______________________________________________
>> talk mailing list
>> talk at lists.nycbug.org
>> http://lists.nycbug.org/mailman/listinfo/talk
> 
> _______________________________________________
> talk mailing list
> talk at lists.nycbug.org
> http://lists.nycbug.org/mailman/listinfo/talk
> 



More information about the talk mailing list