From 99b7c30807d66bfe10ca88a60fb4da2f9be39066 Mon Sep 17 00:00:00 2001 From: onceupon Date: Wed, 11 Apr 2018 10:00:37 +0800 Subject: [PATCH] add sed Remove lines whose nth character not equal to a value --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index c49ed3b..ddfa10b 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,12 @@ sed "/bbo/d" filename - case insensitive: sed "/bbo/Id" filename ``` +##### Remove lines whose nth character not equal to a value (e.g. 5th character not equal to 2) +```bash +sed -E '/^.{5}[^2]/d' +#aaaa2aaa (you can stay) +#aaaa1aaa (delete!) +``` ##### Edit infile (edit and save)