I ran into this problem the other day and I scratch my head for a long time before I found this solution. I better save this one here for future reference 🙂
I just did a simple operation like this:
grep 123456789 files/*
and this resulted in a “bash: /bin/grep: Argument list too long”. The reason for this is that the files directory contains about 24000 files. This is a little to much for grep to handle like that.
but if you do like this it works (takes quite some time though)
find files/ -type f | xargs grep 123456789
What if I want to look for some files with particular extension?
$find /dir/ -type f -name *.pub | xargs grep PRIVATE
-bash: /usr/bin/find: Argument list too long
Hi,
I just tested your command and it seems to work just fine on Red Hat Enterprise Linux AS release 3 (Taroon Update 9) and OSX 10.7.5. Does my original command work on your machine?
this is because *.pub as written still shell-expands.
find /dir/ -name “*.pub” wouldn’t