From 2fcc808e6337dedc852da8a101df54fbcf0b8503 Mon Sep 17 00:00:00 2001 From: Erik Terpstra <39518+eterps@users.noreply.github.com> Date: Tue, 11 Sep 2018 09:22:21 +0200 Subject: [PATCH] Added insert/add line examples Added insert/add line examples. --- cheat/cheatsheets/sed | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cheat/cheatsheets/sed b/cheat/cheatsheets/sed index e22c97a..93bc163 100644 --- a/cheat/cheatsheets/sed +++ b/cheat/cheatsheets/sed @@ -15,3 +15,9 @@ sed '/^$/d' file.txt # To replace newlines in multiple lines sed ':a;N;$!ba;s/\n//g' file.txt + +# Insert a line before a matching pattern: +sed '/Once upon a time/i\Chapter 1' + +# Add a line after a matching pattern: +sed '/happily ever after/a\The end.'