I want to grep only header files in source code. And seems that it is well-known and already solved problem, but --include=
doesn't work for me:
$ grep -rnI --include=\*.h 'static volatile'
net/ipv4/ipconfig.c:174:static volatile int ic_got_reply __initdata; /* Proto(s) that replied */
drivers/mtd/maps/sbc_gxx.c:83:static volatile int page_in_window = -1; // Current page in window.
drivers/parport/parport_mfc3.c:79:static volatile int dummy; /* for trigger readds */
^C
I expect that there will be only header files with .h
extension.
By the way, --exclude=
works fine:
$ grep -rnI --exclude=\*.c 'static volatile'
arch/mips/include/asm/mach-pmcs-msp71xx/msp_gpio_macros.h:63:static volatile u32 * const MSP_GPIO_DATA_REGISTER[] = {
arch/mips/include/asm/mach-pmcs-msp71xx/msp_gpio_macros.h:83:static volatile u32 * const MSP_GPIO_MODE_REGISTER[] = {
arch/arm/mach-w90x900/include/mach/uncompress.h:28:static volatile u32 * const uart_base = (u32 *)UART0_PA;
arch/arm/mach-gemini/include/mach/uncompress.h:19:static volatile unsigned long * const UART = (unsigned long *)GEMINI_UART_BASE;
^C
UPD:
$ grep --version
grep (GNU grep) 2.27
...
$ type grep
grep is aliased to `grep --color --exclude=tags --exclude-dir="build*"'
But it works well when alias is cancelled such way: $ \grep -rnI --include=\*.h 'static volatile'
.
So why does --exclude=
cancels --include=
?