Solved

Find returns too many errors...

Posted on 2004-09-09
4
355 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
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…
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.

707 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