使用 GNU find -regex 查找长文件名

发布于 2024-09-16 20:18:51 字数 238 浏览 10 评论 0原文

我正在尝试使用以下方法查找目录中的所有长文件名:

find . -regex './[^/]\{5,\}.txt' 

根据 GNU find 文档,-regex 默认情况下使用 emacs regex。所以这应该给我所有长度超过 5 个字符的文件(不包括扩展名)。不幸的是它不起作用。它什么都不匹配。我尝试过这个主题的各种变体,但没有成功。有什么想法吗? GNU 是否发现根本不支持重复限定符?

I'm trying to find all long filenames in a directory using:

find . -regex './[^/]\{5,\}.txt' 

According to the GNU find documentation, -regex uses emacs regex by default. So this should give me all files longer than 5 characters (excluding extension). Unfortunately it does not work. It matches nothing. I've tried various variations on this theme but to no avail. Any ideas? Does GNU find simply not support the repetition qualifier?

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

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

发布评论

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

评论(2

故事灯 2024-09-23 20:18:51

添加

-regextype posix-extended

且无需转义 { }

find . -regextype posix-extended -regex './[^/]{5,}.txt' 

Add

-regextype posix-extended

and no need to escape { }

find . -regextype posix-extended -regex './[^/]{5,}.txt' 
离不开的别离 2024-09-23 20:18:51

为什么这么复杂?

find /path -type f -iname "??????*.txt"

why so complicated?

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