为什么这个正则表达式不起作用: find ./ -regex '.*[mh]$' |排序| grep --exclude="UnitTests" *

发布于 2024-11-05 12:42:09 字数 336 浏览 2 评论 0 原文

为什么这个正则表达式不起作用:

   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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

攀登最高峰 2024-11-12 12:42:09

代替使用

find ./ -regex '.*[mh]

--exclude 在递归子目录时使用,但您的 grep 是基于 find ./ -regex '.*[mh 的管道(输出)完成的]$'|排序

| sort | grep -v "UnitTests"

--exclude 在递归子目录时使用,但您的 grep 是基于 find ./ -regex '.*[mh 的管道(输出)完成的]$'|排序

Use

find ./ -regex '.*[mh]

instead. --exclude is used when recursing subdirectories, but your grep is done based on the pipe (the output) from find ./ -regex '.*[mh]$' | sort.

| sort | grep -v "UnitTests"

instead. --exclude is used when recursing subdirectories, but your grep is done based on the pipe (the output) from find ./ -regex '.*[mh]$' | sort.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文