正则表达式:如何匹配包含“ something”的行,但排除以“ a”开头的行,即使它们包含“ something”(区分大小写)?

时间:2019-12-27 14:33:49

标签: regex grep

我想这应该很容易,但是自从我编写了正则表达式以来已经有一段时间了。

说我有一个文件

This line contains something
This one doesn't
And this one shouldn't match, even if it contains something
Also, this one shouldn't match
Something is included here
Here's something else
and finally, a lower case a. Now that's something.

我正在使用grep,这就是我所拥有的

polar@UBFF:~$ tail -fn20 temp.txt | grep "[sS]omething"
This line contains something
And this one shouldn't match, even if it contains something
Something is included here
Here's something else
and finally, a lower case a. Now that's something.

那么,有人可以告诉我如何修改这个非常简单的正则表达式,以排除以“ a”或“ A”开头的行,即使它们包含“ something”?

0 个答案:

没有答案