ITeye博客

Ack Regular expression

夜鸣猪 · 2013-02-15 00:04 · Ruby On Rails · 编程语言 · Markdown

ack uses Perl regular expressions, and those allow lookahead assertions:

^(?!.*bar).*foo.*$

will match a line that contains foo but doesn't contain bar.

I'm not familiar with the usage of ack, but something like this should work:

ack '^(?!.*bar).*foo.*$' myfile

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。