I was using this command find . -type f -exec grep -Hn 'TEXT' {} \; in terminal to find all files where TEXT is in file, but right now I want to find all the files in current directory where TEXT isn't in the file.
            Asked
            
        
        
            Active
            
        
            Viewed 736 times
        
    0
            
            
         
    
    
        user2285522
        
- 65
- 7
- 
                    1possible duplicate of [Using grep to find files that don't contain a given string pattern](http://stackoverflow.com/questions/1748129/using-grep-to-find-files-that-dont-contain-a-given-string-pattern) and [Find files that does not contain a string](http://stackoverflow.com/questions/14809800/find-files-that-does-not-contain-a-string) – Abecee Aug 21 '15 at 22:18
- 
                    Yes, it's a dublicate. Couldn't find this link before. Thanks – user2285522 Aug 21 '15 at 22:34
1 Answers
0
            
            
        All POSIX-compliant grep implementations should have -v option:
-v
Select lines not matching any of the specified patterns. If the -v
option is not specified, selected lines shall be those that match any
of the specified patterns.
So command to list files that do not contain TEXT should be:
$ find . -type f -exec grep -lv 'TEXT' {} \;
 
    
    
        Arkadiusz Drabczyk
        
- 11,227
- 2
- 25
- 38
- 
                    OP asks for "where TEXT isn't in the file", not for lines in the file, not holding the string... – Abecee Aug 21 '15 at 22:27
- 
                    You're probably right. I just copied a command OP has given and added `-v` but `-lv` would be better here. I will fix my answer. – Arkadiusz Drabczyk Aug 21 '15 at 22:33
- 
                    
-