grep linux filename - How do I find files that do not contain a given string pattern?
Take a look at
ack. It does the
.svn exclusion for you automatically, gives you Perl regular expressions, and is a simple download of a single Perl program.
The equivalent of what you're looking for should be, in
ack -L foo
How do I find out the files in the current directory which do not contain the word
The following command excludes the need for the find to filter out the
svn folders by using a second
grep -rL "foo" ./* | grep -v "\.svn"
I had good luck with
grep -H -E -o -c "foo" */*/*.ext | grep ext:0
My attempts with
grep -v just gave me all the lines without "foo".
My grep does not have any -L option. I do find workaround to achieve this.
The ideas are :
- to dump all the file name containing the deserved string to a txt1.txt.
- dump all the file name in the directory to a txt2.txt.
make the difference between the 2 dump file with diff command.
grep 'foo' *.log | cut -c1-14 | uniq > txt1.txt grep * *.log | cut -c1-14 | uniq > txt2.txt diff txt1.txt txt2.txt | grep ">"
grep -irnw "filepath" -ve "pattern"
grep -ve "pattern" < file
above command will give us the result as -v finds the inverse of the pattern being searched