|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
find commnad
Hello,
Anyone knows how to suppress the msg from a 'find'command that said: Quote:
???
__________________
Help me, help you, help others...
|
|
#2
|
|||
|
|||
|
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
__________________
-- Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more. |
|
#3
|
||||
|
||||
|
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? |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
||||
|
||||
|
So the trick is redirect std error to std out so grep can see... yeah works great! You are the best! thx ;-)
|
|
#6
|
|||
|
|||
|
This command is for use in bash shell, not tcsh:
find / -name 'bin' 2>/dev/null |
|
#7
|
|||
|
|||
|
Quote:
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. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > find commnad |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|