Here's one that is loosely based on Rich Homolka's answer, but works on directory trees:
find . -type f -exec grep -l addDesignControlChangeNotification {} \; | while IFS= read -r file; do grep -q removeDesignControlChangeNotification "$file"> /dev/null ; [ $? -ne 0 ] && echo $file; done
Any files returned will contain addDesignControlChangeNotification
but not removeDesignControlChangeNotification
.
EXPLANATION:
find . -type f -exec grep -l foo {} \;
: This will print all files in any subdirectory of the current directory that contain the stringfoo
. The-l
flag causes grep to only print the names of matching files.while read file
: this iterates through each file found above, saving its name in the variable$file
.grep -q bar "$file"> /dev/null
: this comand loks for the stringbar
in each of the files that containedfoo
.[ $? -ne 0 ] && echo $file;
: If the return value ($?
) of thegrep
command was 0 (i.e. if the string was not in the file), print the name of the file.