bganoush
asked on
Find returns too many errors...
When I try to find files on my system, I type:
find / -name "somename" -print
the problem is that when I do this, it not only finds all the filenames that I want, but it also searches through some directories which I do not have access to. So I get thousands of error messages like:
find: cannot chdir to </etc/security> : Permission denied
find: cannot chdir to </etc/ppp> : Permission denied
find: cannot chdir to </opt/lost+found> : Permission denied
and somewhere among these error messages, I can find my files but it takes too long...
Is there a way to only find what I need?
I tried piping to a 'grep 'somename' but that only moves the found files to the end of the error messages.
-- Bubba
Have you considered using 'slocate somefile' instead? It will only print out matches.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Run this:
find / -name "somename" -print 2>/dev/null
This will take all STDERR (2) and send it to /dev/null
find / -name "somename" -print 2>/dev/null
This will take all STDERR (2) and send it to /dev/null
> I can find my files but it takes too long...
start your find at the directory wher you expect the files, like
find /path/where/expected -name "somename" -print 2
or you can do it the long way:
find / \( -name dirwherepermissiondenied -prune -o -name otherdirwherepermissionden ied \) -name "somename" -print 2
> Is there a way to only find what I need?
hmm, either this is the wrong question: why are you using find then?
or the answer is simply:
ls -l /path/where/I/expect/somen ame
I assume that both answers are not what you're expecting. Please rethink about this question and rephrase it.
> slocate somefile
this prerequests that the locate database has been setup correctly before.
The only reliable way is find :-)
start your find at the directory wher you expect the files, like
find /path/where/expected -name "somename" -print 2
or you can do it the long way:
find / \( -name dirwherepermissiondenied -prune -o -name otherdirwherepermissionden
> Is there a way to only find what I need?
hmm, either this is the wrong question: why are you using find then?
or the answer is simply:
ls -l /path/where/I/expect/somen
I assume that both answers are not what you're expecting. Please rethink about this question and rephrase it.
> slocate somefile
this prerequests that the locate database has been setup correctly before.
The only reliable way is find :-)