This groups by basename and grep output:
]# grep -ro '#include' include/ |sed -E 's|.*/(.*:)|\1|' |uniq -c |sort|tail -n7
grep -o to get some duplicates. Same time it leaves out the slashes...
If the names contain
: the sed will not work correctly. The regex first throws away everything until the last
/, then stores everything until a
-E because of the (subexpression) and
| because of the slash.
(.*:) is a bit simple (will fail if a grepped line contains a colon). If you leave out the colon, it will fail when the line contains a slash.
Looking at this output I say this is impossible in theory (to parse grep's output in that way):
]# grep -r "" d*
d:/ir:/afile...in file "d"
d:/ir:/afile...in file "ir"
This is identical. I needed a dir with a colon at the end and a file with overlapping name and contents.
]# ls d*
grep --color makes the difference!
include directory is the one from the linux kernel source. One full line in one include-file looks like this.
]# grep -rH '#incl' include/linux/aio.h