开发者

why isn't this regex working: find ./ -regex '.*[mh]$' | sort | grep --exclude="UnitTests" *

开发者 https://www.devze.com 2023-03-03 20:41 出处:网络
why isn\'t this regex working: find ./ -regex \'.*[mh]$\' | sort | grep --exclude=\"UnitTests\" * The following works:

why isn't this regex working:

   find ./ -regex '.*[mh]$' | sort | grep --exclude="UnitTests" *

The following works:

   find ./ -regex '.*[mh]$' | sort
   find ./ -regex '.*[开发者_如何学运维mh]$' | 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


Use

find ./ -regex '.*[mh]$' | 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号