*.cपैटर्न अपने खोल से मूल्यांकन किया जाता है। यह वर्तमान निर्देशिका पर लागू होता है, जैसे आप उपयोग कर रहे हैं ls *.c।
मुझे लगता है कि आप इसके बजाय जो चाहते हैं, वह है कि *.cपैटर्न से मेल खाती सभी फाइलें (पुनरावर्ती) मिलें और उसमें आपकी grepखोज हो। यहाँ एक तरीका है कि:
find . -name "*.c" -print0 | xargs --null grep -l search-pattern
इसका उपयोग xargsखोज परिणामों को जोड़ने के लिए करता है find।
वैकल्पिक रूप से, -execखोजने के लिए विकल्प का उपयोग करें , उदाहरण के लिए:
find . -name "*.c" -exec grep -l search-pattern "{}" \;
इसके अलावा, मुझे यकीन नहीं है कि आप वास्तव में -lविकल्प चाहते हैं grep। यह पहले मैच में रुकेगा:
-l, --files-with-matches
Suppress normal output; instead print the name of each
input file from which output would normally have been
printed. The scanning will stop on the first match.
(-l is specified by POSIX.)
--include=GLOBविकल्प नहीं पता था । पुनरावर्ती विकल्प के संयोजन में यह बहुत शक्तिशाली है और इसकी आवश्यकता नहीं हैfind। अच्छा!