aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2024-01-23 00:42:12 +0100
committerJohannes Stoelp <johannes.stoelp@gmail.com>2024-01-23 00:42:12 +0100
commit42c4782598dae5728539b24f83ebafc3e33b7448 (patch)
tree18830025f18b43919c995de836dd0a16614b7c0f /src
parent4abeba77c0ade006aff3f2bbafb335ece51fa84c (diff)
downloadnotes-42c4782598dae5728539b24f83ebafc3e33b7448.tar.gz
notes-42c4782598dae5728539b24f83ebafc3e33b7448.zip
sed: delete matching lines
Diffstat (limited to 'src')
-rw-r--r--src/tools/sed.md10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/tools/sed.md b/src/tools/sed.md
index 1746c24..1bd8185 100644
--- a/src/tools/sed.md
+++ b/src/tools/sed.md
@@ -30,6 +30,16 @@ echo -e 'aa\nbb\ncc\ndd' | sed '$d'
# Delete range of lines.
echo -e 'aa\nbb\ncc\ndd' | sed '1,3d'
# dd
+
+# Delete lines matching pattern.
+echo -e 'aa\nbb\ncc\ndd' | sed '/bb/d'
+# aa
+# cc
+# dd
+
+# Delete lines NOT matching pattern.
+echo -e 'aa\nbb\ncc\ndd' | sed '/bb/!d'
+# bb
```
### Insert lines