Louis I. answered 07/11/19
Computer Science Instructor/Tutor: Real World and Academia Experienced
Well, here's a brute force kinda way ... pipe your output into some combination of cut / sort to get a unique sorted list of files that contain the pattern you're searching for. Sounds like that's what you're looking for.
See example and output below:
## show me all C source files that contain a #define definition
find . -iname "*.c" -exec grep -H "^#define" {} \; | cut -d: -f1 | sort -u
./AlexandraK/calc.c
./AlexandraK/calendar.c
./AlexandraK/pyramid.c
./AntonioM/argtester.c
./AntonioM/structs.c
./AntoniqueR/calendar.c
./AntoniqueR/calendar2.c
./AntoniqueR/calLab3Problem2.c
./AntoniqueR/pyramid.c
./AntoniqueR/pyramid2.c
./AR/pyramid.c
./ChrisB/pyramid.c
./ChrisB/t3.c
...... ......
I can't think of a clever way to make this sort of thing the responsibility of grep (or find, for that matter).