Solved

Find returns too many errors...

Posted on 2004-09-09
4
345 Views
Last Modified: 2010-08-05

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
0
Comment
Question by:bganoush
4 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 12019670
Have you considered using 'slocate somefile' instead? It will only print out matches.
0
 
LVL 14

Accepted Solution

by:
chris_calabrese earned 125 total points
ID: 12019841
find / -name "somename" -print 2>/dev/null
0
 

Expert Comment

by:timf04
ID: 12025452
Run this:
find / -name "somename" -print 2>/dev/null

This will take all STDERR (2) and send it to /dev/null
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 12039588
> 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 otherdirwherepermissiondenied \) -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/somename

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 :-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now