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.

Niklas Tech Blog
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.