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
So my question is how can I grep for a specific filetype on Mac?
This one works for me on Mac OS 10.8:
grep --include=*.js -r setHeader .
The best way to do that is to combine the find
and the grep
command:
find . -name "*.js" -exec grep --color=auto setHeader {} \;
grep --include=*.js -R . --color=auto setHeader
Since the example given uses "file type = file extension", this should just work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With