为什么这个正则表达式不起作用:
find ./ -regex '.*[mh]$' | sort | grep --exclude="UnitTests" *
以下有效:
find ./ -regex '.*[mh]$' | sort
find ./ -regex '.*[mh]$' | sort | grep "UnitTests"
当我添加“--exclude”时(因为我想要除其中包含 UnitTests 的行之外的所有内容),我似乎感到悲伤。
我使用的是 Mac OSX
why isn't this regex working:
find ./ -regex '.*[mh]
The following works:
find ./ -regex '.*[mh]
When I'm adding the "--exclude" (as I want everything but lines with UnitTests in them) I seem to come to grief.
I'm on Mac OSX
| sort | grep --exclude="UnitTests" *
The following works:
When I'm adding the "--exclude" (as I want everything but lines with UnitTests in them) I seem to come to grief.
I'm on Mac OSX
| sort
find ./ -regex '.*[mh]
When I'm adding the "--exclude" (as I want everything but lines with UnitTests in them) I seem to come to grief.
I'm on Mac OSX
| sort | grep --exclude="UnitTests" *
The following works:
When I'm adding the "--exclude" (as I want everything but lines with UnitTests in them) I seem to come to grief.
I'm on Mac OSX
| sort | grep "UnitTests"
When I'm adding the "--exclude" (as I want everything but lines with UnitTests in them) I seem to come to grief.
I'm on Mac OSX
| sort | grep --exclude="UnitTests" *
The following works:
When I'm adding the "--exclude" (as I want everything but lines with UnitTests in them) I seem to come to grief.
I'm on Mac OSX
发布评论
评论(1)
代替使用
。
--exclude
在递归子目录时使用,但您的grep
是基于find ./ -regex '.*[mh 的管道(输出)完成的]$'|排序
。Use
instead.
--exclude
is used when recursing subdirectories, but yourgrep
is done based on the pipe (the output) fromfind ./ -regex '.*[mh]$' | sort
.