如何使用 find 实用程序匹配文件 *.R 和 *Rd? [英] How to match files *.R and *Rd with find utility?

查看:14
本文介绍了如何使用 find 实用程序匹配文件 *.R 和 *Rd?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想查找所有以 .c.R.Rd 结尾的文件.我试过了

I would like to find all files that end with .c, .R, or .Rd. I tried

find . -iname "*.[cR]" -print

给出所有以 .c.R 结尾的文件.我怎样才能另外获取 .Rd 文件?我知道 [] 只匹配一个字符,但我无法调整它以提供 .Rd 文件(尝试使用 | 或选项 -regex 等)

which gives all files that end with .c or .R. How can I additionally get .Rd files as well? I know that [] only matches one character, but I couldn't adjust it to provide .Rd files as well (tried to work with | or option -regex etc.)

推荐答案

给你=)

find -name "*.c" -o -name "*.R" -o -name "*.Rd"

如果它只是您正在寻找的 3 种扩展类型,我建议您远离正则表达式,而只使用 -o(如or")运算符来组成您的搜索.

If it's just the 3 extension types that you are looking for, I'd recommend staying away from regex and just using the -o (as in "or") operator to compose your search instead.

这篇关于如何使用 find 实用程序匹配文件 *.R 和 *Rd?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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