I need to locate .php
and .pl
files that do not contain one string (e.g. aaa
), but do contain another (e.g. bbb
).
I'm currently using this command:
find /path/ \( -iname '*.php*' -or -name '*.pl*' \) -exec sh -c 'grep -l -v "aaa" {} | grep -l "bbb" {}' \; > resulttofile
It's about half a million files to search, so I'm wondering,
- If my command works correctly - some eye sampling gives positive result,
- If it's possible to become faster (it currently takes about 2min on a VM, but more files will be added) using some other form, or
awk
orsed
instead ofgrep
- or perhaps just one combinedgrep
instead of two.
The system is a Debian GNU/Linux.
grep
orfind
. – terdon Apr 28 '23 at 11:03aaa
butbbb
” is confusing — “aaa
but notbbb
” would be clearer. – G-Man Says 'Reinstate Monica' Apr 30 '23 at 06:40