LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-07-2009, 03:13 AM   #1
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 537

Rep: Reputation: 32
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?
 
Old 08-07-2009, 03:21 AM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
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.
 
Old 08-07-2009, 03:23 AM   #3
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: pclinuxos slackware64 tails kali
Posts: 3,372
Blog Entries: 33

Rep: Reputation: 217Reputation: 217Reputation: 217
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

Last edited by GlennsPref; 08-07-2009 at 03:24 AM. Reason: Simon beat me to it, lol
 
Old 08-07-2009, 03:50 AM   #4
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 537

Original Poster
Rep: Reputation: 32
Many thanks!
 
Old 08-07-2009, 04:54 AM   #5
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to use find to build a list of files with *.cpp *.h *.cc *.mm *.java extensions n179911 Linux - Newbie 3 07-08-2009 01:14 PM
Script to reclusively find all media (mp3) files and make a list tommytomthms5 Linux - Newbie 13 10-15-2008 07:53 PM
How to find files and copy the found files to the floppy in one command justmehere Linux - Newbie 11 05-04-2008 11:29 PM
Need to find if a matching file exist from a list of possible file names wit_273 Linux - General 5 10-25-2007 09:47 AM
find and list files modified since system was booted Mike144 Linux - Newbie 5 04-09-2006 08:03 PM


All times are GMT -5. The time now is 04:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration