I would like to know which files do not include a particular header file in C.
For example:
file1.c
#include "stdio.h"
#include "my.h"
...
file2.c
#include "stdio.h"
....
I would like to find out simila开发者_开发问答r files (like file2.c) which do not contain #include "my.h"
.
On Unix systems:
grep -L '#include.*my\.h' *.c
shopt -s nullglob
for file in *.c
do
if grep -q "my.h" "$file" ;then
continue
else
echo "found file that don't have my.h"
fi
done
Or you could use:
grep -L "my.h" *.c
if you have nothing else to process except to echo out file names. :)
精彩评论