Grep recursion - inconsistencies

I am looking for a specific line (mainly in .c files) recursively from the root directory.

When I use this, I get the list almost immediately.

grep -rl "F_capture" . 

However, if I try to speed up the process by simply searching for .c files:

 grep -r --include=*.c "F_capture" . 

As a result, I get a lot of recursive directory warnings, for example:

 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 to suppress warnings using the -s option, I don't get a warning, but I get nothing - it seems like it is leaving to never land.

 grep -rsl --include="*.c" "F_capture" . 

So, I think my question is why the first grep I used returned something right away, and the other types in which I am configured for a specific file type seem to freeze. I think targeted searches will be faster.

+6
source share
2 answers

You can try the following:

 find . -type f -name "*.c" -print|xargs grep -l "F_capture" 
+1
source

Try the following command:

 grep "F_capture" `find -type f -name "*.c"` 
0
source

Source: https://habr.com/ru/post/972051/


All Articles