I'm trying to determine which header declares a specific function. I've used grep
to find instances of the function's use; now, I want to find which header is included by all the files. I'm aware of the comm
utility; however, it can only compare two sorted files. Is there a Unix utility that can find the common lines between an arbitrary number of unsorted files, or must I write my own?
cat *.c | sort | uniq -c | grep -e '^ *COUNT #include'
where COUNT
is the number of files passed to cat
. In playing around, I used this variant to see what files I #include at least 10 times:
cat *.c | sort | uniq -c | grep -e '^ *[0-9][0-9]\+ #include'