diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-01-23 00:42:12 +0100 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-01-23 00:42:12 +0100 |
commit | 42c4782598dae5728539b24f83ebafc3e33b7448 (patch) | |
tree | 18830025f18b43919c995de836dd0a16614b7c0f | |
parent | 4abeba77c0ade006aff3f2bbafb335ece51fa84c (diff) | |
download | notes-42c4782598dae5728539b24f83ebafc3e33b7448.tar.gz notes-42c4782598dae5728539b24f83ebafc3e33b7448.zip |
sed: delete matching lines
-rw-r--r-- | src/tools/sed.md | 10 |
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 |