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
Solved

Find returns too many errors...

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

828 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