[talk] insert line after matched pattern (fwd)

freebsd at fongaboo.com freebsd at fongaboo.com
Wed Aug 19 12:48:06 EDT 2015


This worked well. Thank you!


On Wed, 19 Aug 2015, Steven Kreuzer wrote:

>
>> On Aug 19, 2015, at 11:59 AM, 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?
>
>
> With awk:
>
> $ echo 'FIRST_LINE\nLAST_LINE' | awk '1;/FIRST_LINE/{print "NEWLINE"}'
> FIRST_LINE
> NEWLINE
> LAST_LINE
>
> The '1' is a shortcut for {print} so it will always print the line. However, if FIRST_LINE gets matched, it will also print NEWLINE




More information about the talk mailing list