LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to find a file and just list the found files? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-find-a-file-and-just-list-the-found-files-745756/)

thomas2004ch 08-07-2009 03:13 AM

How to find a file and just list the found files?
 
I use find / -name myfile to search files. But it will print out a very long list such as follow:
Code:

...
find: /var/empty/sshd: Permission denied
find: /etc/audit: Permission denied
find: /etc/httpd/conf/ssl.crl: Permission denied
find: /etc/httpd/conf/ssl.crt: Permission denied
find: /etc/httpd/conf/ssl.csr: Permission denied
find: /etc/httpd/conf/ssl.key: Permission denied
find: /etc/httpd/conf/ssl.prm: Permission denied
/etc/httpd/conf/workers.properties
find: /root: Permission denied
find: /usr/share/ssl/CA: Permission denied
find: /usr/netiq/UnixAgent: Permission denied
find: /usr/netiq/jre: Permission denied
[a5xsuuser@s003ap06 conf]$ ll /opt/iplanet6/plugins/nsapi/
...

What I want is just the found list such as follow:

Code:

...
/etc/httpd/conf/workers.properties
[a5xsuuser@s003ap06 conf]$ ll /opt/iplanet6/plugins/nsapi/
...

Someone can help?

Simon Bridge 08-07-2009 03:21 AM

All those are "permission denied" ... the easy way to get rid of them is not look there.
Use find only on parts of the tree you have permission to look in.
This also makes the search faster.

The next best thing is to pipe the error messages to the bitbucket ... I'll explain:

find / -name "myfile" -print 2> /dev/null

You can also try

locate

... which will find indexed files.

GlennsPref 08-07-2009 03:23 AM

Hi, try

locate file-name

But it will find anything with those "file-name" characters.

Locate may be packaged as mlocate, slocate, etc.

Update the database locate needs, type

updatedb

you may need root access to run this.

see how you go.

cheers Glenn

thomas2004ch 08-07-2009 03:50 AM

Many thanks!

Simon Bridge 08-07-2009 04:54 AM

Cool! Please notice the thumbs-up icon at the bottom of each post... better yet: go find someone else to help.


All times are GMT -5. The time now is 12:16 PM.