The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Operating Systems
> UNIX Help
|
find commnad
Discuss find commnad in the UNIX Help forum on Dev Shed. find commnad UNIX Help forum discussing the Unix Operating System and all variants including Irix, Solarix, and AIX. Unix was designed as a true multi-user operating system.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 14th, 2002, 07:24 AM
|
 |
Contributing User
|
|
Join Date: Sep 2002
Location: Orlando FL
Posts: 130
Time spent in forums: < 1 sec
Reputation Power: 11
|
|
|
find commnad
Hello,
Anyone knows how to suppress the msg from a 'find'command that said:
Quote: | find: cannot read dir /lost+found: Permission denied |
???
__________________
Help me, help you, help others...
|

November 14th, 2002, 11:51 AM
|
|
Contributing User
|
|
Join Date: Oct 2000
Location: Back in the real world.
|
|
|
you could use
find ....... |grep -v "cannot read dir /lost+found: Permission denied"
or if you want to suppress all error messages use
find ...... 2>/dev/null
|

November 25th, 2002, 07:34 AM
|
 |
Contributing User
|
|
Join Date: Sep 2002
Location: Orlando FL
Posts: 130
Time spent in forums: < 1 sec
Reputation Power: 11
|
|
|
Hi, thanks for writing. Sorry I was out for a while and now I am back. Anyway, I tried your tips but still doesn't work.
MY ORIGINAL PROBLEM/QUESTION STARTED LIKE THIS:
tiger[zdeng]% find / -name 'bin'
find: cannot read dir /lost+found: Permission denied
find: cannot read dir /usr/lost+found: Permission denied
/usr/lib/lp/bin
/usr/sadm/lib/smc/bin
^C
THE GREP SOLUTION:
tiger[zdeng]% find / -name 'bin' |grep -v 'find: cannot read dir /lost+found'
find: cannot read dir /lost+found: Permission denied
find: cannot read dir /usr/lost+found: Permission denied
^C
THE STD ERROR REDIRECT SOLUTION:
tiger[zdeng]% find / -name 'bin' 2> /dev/null
find: bad option 2
find: path-list predicate-list
I am using tcsh as shell. More suggestion?
|

November 25th, 2002, 01:02 PM
|
|
Contributing User
|
|
Join Date: Oct 2000
Location: Back in the real world.
|
|
yes
for the grep - it could not work since find does write the errors to stderr.
so it has to be:
find / -name 'bin' 2>&1 |grep -v 'find: cannot read dir /lost+found'
The redirection would work in bash. for tcsh, use:
find / -name 'bin' |& grep -v 'find: cannot read dir /lost+found'
to suppress all error messages, you need to switch shells as tcsh cannot redirect stderr only.
|

November 25th, 2002, 01:29 PM
|
 |
Contributing User
|
|
Join Date: Sep 2002
Location: Orlando FL
Posts: 130
Time spent in forums: < 1 sec
Reputation Power: 11
|
|
|
So the trick is redirect std error to std out so grep can see... yeah works great! You are the best! thx ;-)
|

November 6th, 2003, 02:57 PM
|
|
Junior Member
|
|
Join Date: Nov 2003
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
This command is for use in bash shell, not tcsh:
find / -name 'bin' 2>/dev/null
|

November 6th, 2003, 03:07 PM
|
|
Contributing User
|
|
Join Date: Oct 2000
Location: Back in the real world.
|
|
Quote: Originally posted by ryofnott
This command is for use in bash shell, not tcsh:
find / -name 'bin' 2>/dev/null |
Ok, kids: What does the author want to tell us? Read between the lines!
He clearly states that redirecting stderr to stdout is an act of oppression against harmless processes done by agressive forces straight from (s)hell.
Eat your supper, or you'll all be doomed!
...M
Last edited by M.Hirsch : November 6th, 2003 at 03:10 PM.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|