Skip to content

Instantly share code, notes, and snippets.

@sevaine
Created June 28, 2017 04:02
Show Gist options
  • Save sevaine/c6e34482332f364f7e39d7254316dafb to your computer and use it in GitHub Desktop.
Save sevaine/c6e34482332f364f7e39d7254316dafb to your computer and use it in GitHub Desktop.
insert multi-line string before or after match with sed
# insert before match
sed -i '/PATTERN/ s|^|LINE1\nLINE2\nLINE3\n|' FILE
# insert after match
sed -i '/PATTERN/ s|$|\nLINE1\nLINE2\nLINE3|' FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment