Unix 查找:多种文件类型 [英] Unix find: multiple file types

查看:26
本文介绍了Unix 查找:多种文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对多种文件类型运行 find -name.例如.

I want to run find -name with multiple file types. Eg.

 find -name *.h,*.cpp

这可能吗?

推荐答案

$ find . -name '*.h' -o -name '*.cpp'

要在 man 页面中查找此信息,请键入 man find 并通过键入 /OPERATORS 并按回车键来搜索运算符.

To find this information in the man page, type man find and the search for operators by typing /OPERATORS and hit enter.

. 对于 GNU find 来说不是绝对必要的,但在 Unix 中是必要的.引号在任何一种情况下都很重要,如果这些类型的文件出现在当前目录中,将它们省略会导致错误.

The . isn't strictly necessary with GNU find, but is necessary in Unix. The quotes are important in either case, and leaving them out will cause errors if files of those types appear in the current directory.

在某些系统(例如 Cygwin)上,需要括号来使扩展集包含在内:

On some systems (such as Cygwin), parentheses are necessary to make the set of extensions inclusive:

$ find . ( -name '*.h' -o -name '*.cpp' )

这篇关于Unix 查找:多种文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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