加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

带有find命令的regextype

发布时间:2020-12-14 00:28:47 所属栏目:Linux 来源:网络整理
导读:我试图使用- regextype的find命令,但它无法正常工作. 我试图找到所有c和h文件发送到管道和grep名称,func_foo在这些文件中.我错过了什么? $find ./ -regextype sed -regex ".*[c|h]" | xargs grep -n --color func_foo 同样在类似的方面我尝试了以下命令,但
我试图使用- regextype的find命令,但它无法正常工作.

我试图找到所有c和h文件发送到管道和grep名称,func_foo在这些文件中.我错过了什么?

$find ./ -regextype sed -regex ".*[c|h]" | xargs grep -n --color func_foo

同样在类似的方面我尝试了以下命令,但它给我一个错误,像路径必须在表达式之前:

$find  ./  -type  f  "*.c"  |  xargs  grep  -n  --color  func_foo

解决方法

为什么不这样做:

find ./ -name "*.[c|h]" | xargs grep -n --color func_foo

find ./ -type f -name "*.c" | xargs grep -n --color func_foo

关于找到选项-regextype的有效参数,这从man发现是逐字的:

-regextype type

Changes the regular expression syntax understood by -regex and -iregex tests which occur later on
the command line. Currently-implemented types are emacs (this is the default),
posix-awk,posix-basic,posix-egrep and posix-extended

没有类型sed.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读