正则表达式 - 发现不匹配的文件 [英] regex - find files that don't match

查看:137
本文介绍了正则表达式 - 发现不匹配的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个目录列表,其中大部分都是像的格式./ [foobar的] / 。然而,一些被格式化像 ./ [富]酒吧/

I have a list of directories where most are in a format like ./[foobar]/. However, some are formatted like ./[foo] bar/.

我想用找到(或其他一些公用事业我的壳报价)找到这些目录中的的匹配第一模式(即有在方括号外面的文字)。到现在为止,我无法找到一个方法来逆我的模式。

I would like to use find (or some other utility my shell offers) to find those directories not matching the first pattern (i.e. having text outside the square braces). Until now, I was unable to find a way to "inverse" my pattern.

要做到这一点任何方式?

Any ways to do this?

推荐答案

您可以找到结合使用grep和它的-v选项。 找到。型开发| grep的-v[foobar的]

You could combine find with grep and it's -v option. find . -type d | grep -v "[foobar]"

这篇关于正则表达式 - 发现不匹配的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆