How do I insert a newline/linebreak after a line using sed

For adding a newline after a pattern, you can also say:

sed '/pattern/{G;}' filename

Quoting GNU sed manual:

G
    Append a newline to the contents of the pattern space, and then append the contents of the hold space to that of the pattern space.

EDIT:

Incidentally, this happens to be covered in sed one liners:

 # insert a blank line below every line which matches "regex"
 sed '/regex/G'

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)