Grep – Argument list too long

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

Comments are closed.