Solved

Find returns too many errors...

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
nodeip 9 68
how to check for shares on aix 1 51
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 49
unix example issues 18 49
When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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.

757 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

23 Experts available now in Live!

Get 1:1 Help Now