Yasir
Yasir

Reputation: 9

List each file that doesn't match a pattern recursively

Tried the following command, it lists all the lines including file names
which are not matching the given pattern.

grep -nrv "^type.* = .*"

"But what we need is list of file names in a folder with content
which does not have even a single occurrence of above pattern."

Your help will be really appreciated.

Upvotes: 0

Views: 89

Answers (1)

M. Nejat Aydin
M. Nejat Aydin

Reputation: 10123

You need the -L option:

grep -rL '^type.* = .*' directory_name

From the GNU grep manual:

-L, - -files-without-match
    Suppress normal output; instead print the name of each input file from which no output
    would normally have been printed. The scanning will stop on the first match.

Upvotes: 1

Related Questions