2012-10-12 38 views
22

मैं एक स्थानीय svn निर्देशिका grepping हूँ। ./Data/test: इस तरह के कोई फ़ाइल या निर्देशिकारिकर्सिव grep क्यों 'ऐसी कोई फ़ाइल या निर्देशिका' त्रुटियों को दिखाता है?

कौन grep पूछा न के बराबर फाइलों को देखने के लिए जब मैं grep -r "pattern" . चलाने मैं ऐसे

रूप

ग्रेप कुछ त्रुटियों मिल सकता है?


>grep --version 
grep (GNU grep) 2.10 

>lsb_release -a 
No LSB modules are available. 
Distributor ID: Ubuntu 
Description: Ubuntu 12.04 LTS 
+1

क्या है '/ डेटा/test'? grep इस प्रकार की त्रुटि को थका सकता है जब यह किसी प्रतीकात्मक लिंक से मुकाबला करता है जो एक अस्तित्वहीन फ़ाइल को इंगित करता है। –

+0

@ j.w.r ऐसा लगता है कि यह एक टूटा प्रतीकात्मक लिंक है (फ़ाइल कमांड के अनुसार)। – user13107

+0

http://stackoverflow.com/questions/6426363/how-can-i-have-grep-not-print-out-no-such-file-or-directory-errors – GlennG

उत्तर

21

डिफ़ॉल्ट रूप से, ग्रेप न के बराबर या पढ़ने योग्य नहीं फ़ाइलों को अनदेखा नहीं होता। ऐसा करने के लिए आपको -s या --no-messages विकल्प प्रदान करने की आवश्यकता है। man grep से हवाला देते हुए:।

-s, --no-messages 
      Suppress error messages about nonexistent or unreadable files. 
      Portability note: unlike GNU grep, 7th Edition Unix grep did not 
      conform to POSIX, because it lacked -q and its -s option behaved 
      like GNU grep's -q option. USG-style grep also lacked -q but 
      its -s option behaved like GNU grep. Portable shell scripts 
      should avoid both -q and -s and should redirect standard and 
      error output to /dev/null instead. (-s is specified by POSIX.) 
+4

धन्यवाद का डुप्लिकेट। वास्तव में मौजूद नहीं हैं/अपठनीय फ़ाइलें क्या हैं? – user13107

+3

गैर-अस्तित्व का एक उदाहरण टूटा सिमलिंक होगा। अपठनीय, जैसा कि शब्द सुझाता है, उन फ़ाइलों को संदर्भित करता है जिनके लिए वर्तमान उपयोगकर्ता को पढ़ने की अनुमति नहीं है। – devnull

+0

grep मेरे लिए '.sql' फ़ाइलें नहीं पढ़ रहा है –