3

I need to put multiple matches on a line each on a new line

example:

grep "banana"


This is the output

Apple banana orange banana lemon

melon banana

grapes apple banana

I want to become:

Apple banana orange

banana lemon

melon banana

grapes apple banana

I want to put all until the next match on a line

1 Answer 1

1

With GNU sed:

sed 's/\(.*banana.*\)\(banana.*\)/\1\n\2/' file
3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .