How to find file that is missing a required string

2019-09-14 07:28发布

问题:

On my OS X command line, I would like to find all files ending in .per that are missing the string 'connection_id'.

How do I go about doing this. Finding the files that have a given string is easy but am not sure how to do this if the string is missing.

Thanks!

回答1:

find . -name '*.per' \! -exec grep -q 'connection_id' {} \; -print