Remove lines whose nth character not equal to a value
This commit is contained in:
onceupon
2018-04-11 10:00:37 +08:00
committed by GitHub
parent d21abd8ddc
commit 99b7c30807

View File

@ -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)