?
Solved

Find returns too many errors...

Posted on 2004-09-09
4
Medium Priority
?
356 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 500 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
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.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month9 days, 3 hours left to enroll

765 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