The other day I was searching for a particular email file in an Maildir on one of our mail servers. Knowing only the From address, I thought I’d use
grep. Unfortunately it failed and gave me an error:
/bin/grep: Argument list too long. Here is how to overcome this grep error…
How to grep through a large number of files? For example:
grep -r "example\.com" * -bash: /bin/grep: Argument list too long
Well, this was no wonder, since there are over 190500 files in that particular Maildir:
ls -1 | wc -l 190516
There are several ways of overcoming this error message. One, for instance is:
find . -type f | xargs grep "example\.com"
A second option to overcome the error is: substitute the “
*” (asterisk) with a “
.” (dot), like:
grep -r "example\.com" .
In newer versions of grep you can omit the “
.“, as the current directory is implied.
My name is Jan. I am not a hacker, coder, developer, programmer or guru. I am merely a system administrator, doing my daily thing at Vevida in the Netherlands. With over 15 years of experience, my specialties include Windows Server, IIS, Linux (CentOS, Debian), security, PHP, WordPress, websites & optimization. Want to support me and donate? Use this link: https://paypal.me/jreilink.
Release hold queue email in Postfix – postsuper
Recursive scp and symlinks
Install Varnish Cache on CentOS 6.7
Install Elasticsearch on CentOS 6.7
Generate pseudo-random passwords with OpenSSL
Turn off swap
New Open-Xchange merger: PowerDNS
Monit monitoring on Ubuntu 14.04 VM on Hyper-V