Question: How do I find all files that do not contain specific text on Linux?
Answer: There could be a number of ways to find files not containing specific text in Linux command line. My favorite way is to use Grep command here.
This is similar to what I did for finding all files containing specific text. You can use the same Grep command with option ‘L’ instead of ‘l’ to achieve this.
grep -RiL "specific_text" <search_directory>
- R option search recursively in subdirectories and in symbolic links
- i option is for case-insensitive search
- L option will print only the name of the files that do not contain the specific text
This will help you find all the files that do not contain the specified string in the given directory and its subdirectories.
Do you use some other way to find all files not matching the string in Linux? Do share it with us in the comment section.