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
awkorsedinstead ofgrep- or perhaps just one combinedgrepinstead of two.
The system is a Debian GNU/Linux.
greporfind. – terdon Apr 28 '23 at 11:03aaabutbbb” is confusing — “aaabut notbbb” would be clearer. – G-Man Says 'Reinstate Monica' Apr 30 '23 at 06:40