MAC上的grep特定文件类型 [英] grep specific filetypes on MAC
本文介绍了MAC上的grep特定文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一台Mac OS X雪豹。我使用xterm终端grep特定字符串使用此命令 grep -R --color = auto setHeader * .js
但是当我运行这个命令时,我得到错误说
I have a Mac OS X snow leopard. I am using the xterm terminal to grep specific string using this command grep -R --color=auto setHeader *.js
but when I run this command I get the error saying
grep: \*.js: No such file or directory
所以我的问题是我如何在Mac上grep特定的文件类型?
So my question is how can I grep for a specific filetype on Mac?
推荐答案
最好的方法是将 find
和 grep
命令结合起来:
The best way to do that is to combine the find
and the grep
command:
find . -name "*.js" -exec grep --color=auto setHeader {} \;
这篇关于MAC上的grep特定文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文