Reputation: 59449
What this question isn't asking is how to add a new line below or above every line which matches a pattern.
What I'm trying to do is add a new line between a pattern that exists on one line.
Here is an example.
before:
Monday:8am-10pm
after:
Monday:
8am-10pm
Thus in this case, insert new line after every 'Monday' pattern.
Upvotes: 1
Views: 11149
Reputation:
sed 's/Monday:/&\n\n/g'
will replace them (supposing you want 2 newlines as shown above)
Upvotes: 2
Reputation: 90012
echo 'Monday:8am-10pm' | sed -e 's/^Monday:/&\n/'
For characters up to ':
':
echo 'Monday:8am-10pm' | sed -e 's/^[^:]*:/&\n/'
Upvotes: 6