Monday, May 6, 2024
 Popular · Latest · Hot · Upcoming
29
rated 0 times [  29] [ 0]  / answers: 1 / hits: 25792  / 3 Years ago, mon, june 28, 2021, 6:15:30

I tried to recursively search a pattern in all the .c files in the following way



> grep -lr search-pattern *.c


But got this as the output



> grep: *.c: No such file or directory


When I use this:



> grep -lr search-pattern *


I get plenty of . c files in the directories with the pattern.



What is wrong with the earlier expression?


More From » grep

 Answers
3

I suggest to use the --include option of grep:



grep -lr --include='*.c' search-pattern .

[#30326] Tuesday, June 29, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ousear

Total Points: 395
Total Questions: 114
Total Answers: 89

Location: Jordan
Member since Thu, Aug 5, 2021
3 Years ago
ousear questions
Tue, Sep 27, 22, 03:29, 2 Years ago
Thu, Nov 25, 21, 00:51, 3 Years ago
Tue, Feb 22, 22, 17:47, 2 Years ago
;