Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grep recursion - inconsistencies

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.

like image 650
stackbacker Avatar asked Jul 10 '14 20:07

stackbacker


1 Answers

You can try this:

find . -type f -name "*.c" -print|xargs grep -l "F_capture"
like image 128
COLINHY Avatar answered Nov 10 '22 11:11

COLINHY