LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-07-2009, 06:56 PM   #1
n179911
LQ Newbie
 
Registered: Jul 2009
Posts: 8

Rep: Reputation: 0
How to configure 'grep' to ignore 'No such file or directory


Hi,

When I try 'grep' like this 'grep -r Test .', I get a lot of errors 'No such file or directory'.

Example:
grep: ./frameworks/opt/com.google.android/.git/packed-refs: No such file or directory
grep: ./frameworks/opt/com.google.android/.git/rr-cache: No such file or directory
grep: ./frameworks/opt/com.google.android/.git/svn: No such file or directory

Can you please tell me how can I configure grep to ignore those errors?

Thank you.
 
Old 07-07-2009, 07:22 PM   #2
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 97
The simplest way is probably to throw the errors away. They'll be output to stderr, and you can simply redirect this to /dev/null (a.k.a "the bit bucket"):

Code:
grep -r Test . 2>/dev/null # stderr has "file descriptor" 2
 
Old 07-07-2009, 08:28 PM   #3
karamarisan
Member
 
Registered: Jul 2009
Location: Illinois, US
Distribution: Fedora 11
Posts: 374

Rep: Reputation: 55
grep has a -s option to deal with this, as well.
 
Old 07-08-2009, 03:57 AM   #4
jeromeNP7
Member
 
Registered: Jun 2009
Posts: 101

Rep: Reputation: 19
Shouldn't that be '&2>/dev/null' instead of '2>/dev/null'? So far I've always seen this with the ampersand sign in front of it ...

Linux

Last edited by jeromeNP7; 09-04-2009 at 09:06 PM.
 
Old 07-08-2009, 04:14 AM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Quote:
Originally Posted by jeromeNP7 View Post
Shouldn't that be '&2>/dev/null' instead of '2>/dev/null'? So far I've always seen this with the ampersand sign in front of it ...
&> means "redirect both standard output and standard error", but if you want to redirect only standard error you have to use 2>. More details in the Advanced Bash Scripting Guide, here.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I "cat" or "grep" a file to ignore lines starting with "#" ??? callagga Linux - Newbie 7 08-16-2013 06:58 AM
bash: ./configure: No such file or directory zaphanol Linux - Software 17 02-09-2010 09:24 AM
./configure: no such file or directory Matthew T. Linux - Newbie 7 07-11-2007 06:20 AM
./configure: No such file or directory abridge Linux - Newbie 5 04-07-2005 11:52 AM
grep: /usr/lib/libglib-2.0.la: No such file or directory FirstTimeUser Linux - Software 9 10-15-2003 09:53 PM


All times are GMT -5. The time now is 02:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration