# Remove all files containing a pattern

bashregex

Suppose I have a directory with files and subdirectories underneath it. Some of the files contain a pattern "^File:" in their contents.

Is there some way I can use grep and a bash command to remove files that contain this pattern? Note I am talking about contents of the file, not the filenames.

find /path/to/dir -type f -exec egrep -Il '^File:' {} \;|xargs rm -fv