Reputation: 329
I'm looking for a particular string (mainly in .c files) recursively from the root directory.
When I use this, I get a list back almost immediately.
grep -rl "F_capture" .
However, if I try to speed things up by just searching .c files:
grep -r --include=*.c "F_capture" .
I end up with a slew of recursive directory warnings like this:
grep: warning: ./sys/block/fd0/device/bus/drivers/i8042/i8042/serio1/input:event1/subsystem/event3/device/bus/drivers/pcnet32/0000:00:03.0/subsystem: recursive directory loop
When I tried suppressing the warnings using the -s parameter, I don't get the warnings but I don't get anything back either - seems like it's going off into never never land.
grep -rsl --include="*.c" "F_capture" .
So I guess my question is, why does the first grep I used return something immediately and the other types where I'm targeting a specific type of file seem to hang up. I would think the targeted search would be faster.
Upvotes: 6
Views: 265
Reputation: 141
Try the following command:
grep "F_capture" `find -type f -name "*.c"`
Upvotes: 0
Reputation: 395
You can try this:
find . -type f -name "*.c" -print|xargs grep -l "F_capture"
Upvotes: 1