I'm using Mac 10.7.5 and on a bash shell. I'm trying to find instances of a string in a group of files but keep getting this error
Daves-MacBook-Pro:folder davea$ find . -name "*" | xargs grep 'state-icons'
xargs: grep: Argument list too long
How can I run the command (or a similar one) to avoid this error?
Best Answer
You can use the
-n
option ofxargs
to limit the number of arguments.But a better solution is to use
-type f
instead of-name "*"
in order to limit the list to ordinary files, avoiding the error message for each folder.Note that it does not work for files with whitespace in their names.