From 42c4782598dae5728539b24f83ebafc3e33b7448 Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Tue, 23 Jan 2024 00:42:12 +0100 Subject: sed: delete matching lines --- src/tools/sed.md | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/tools/sed.md') 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 -- cgit v1.2.3