Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
07-12-2010, 11:44 AM
|
#1
|
|
Member
Registered: Jun 2007
Distribution: Debian Squeeze
Posts: 445
Rep:
|
Find not searching subdirectories
I tried searching for files in documents:
joe@Debian:~/documents$ find -iname *.odt
./canadian-public-holidays.odt
I then moved to the work_search directory which is located in documents:
cd work_search
joe@Debian:~/documents/work_search$
joe@Debian:~/documents/work_search$ find -iname *.odt
Find finds more .odt files in the subdirectories.
./search/applications/sent/2009/7.13.bindery/2009.07.13.asap-print-depot-attach.odt
./search/applications/sent/2009/7.13.bindery/2009.07.13.all-canadian-printing-attach.odt
./search/applications/sent/2009/7.13.bindery/2009.07.13.signature-press-attach.odt
./search/applications/sent/2009/7.13.bindery/2009.07.13.octavia+co-press-attach.odt
./search/applications/sent/2009/7.13.bindery/2009.07.13.central-web-calgary-atttach.odt
./search/applications/sent/2009/7.13.bindery/2009.07.13.apache-superior-printing-attach.odt
./search/applications/sent/2009/7.13.bindery/2009.07.13.kallen-graphics-attach.odt
./search/applications/sent/2009/7.13.bindery/2009.07.13.copy-repro-inc-attach.odt
./search/applications/sent/2009/7.13.bindery/2009.07.13.mcAra-printing-attach.odt
./search/applications/sent/2009/7.13.bindery/2009.07.13.active-bindery-attach.odt
./search/applications/sent/2009/7.13.bindery/2009.07.13.bolder-graphics-attach.odt
Why didn't find locate these files from the documents directory; I thought it was
supposed to search all the subdirectories; when I changed into work_search it searched
the subdirectories under it? what am I not understanding here?
Thanks
|
|
|
|
07-12-2010, 12:19 PM
|
#2
|
|
Senior Member
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,560
Rep: 
|
You need to prevent the shell from expanding the *:
Code:
find -iname '*.odt'
|
|
|
|
07-12-2010, 12:25 PM
|
#3
|
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,797
|
Don't you also need to specify the search path (or maybe it defaults to current directory)?
for many reasons, I now ALWAYS do find thusly:
assume the search term is "fred"
find <path> -name "*fred*" (finds all files with a name containing "fred" anywhere.
|
|
|
|
07-12-2010, 12:36 PM
|
#4
|
|
Guru
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,002
|
locate is excellent, and pre-installed on all the distros I've used. It's much faster than find
If you get too much information, narrow it down with grep to select things in the /path/to/file that you think might apply. Eg:
Code:
locate .odt | grep Documents
The locate database is generally updated daily, so if you want to locate a very recent file, update the database first by running (as root) then run locate
|
|
|
|
07-12-2010, 12:37 PM
|
#5
|
|
Senior Member
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,560
Rep: 
|
i think linux defaults to ., while bsd doesn't. best to always specify the path, as pixellany says.
|
|
|
|
07-12-2010, 04:39 PM
|
#6
|
|
Senior Member
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 3,671
|
Quote:
Originally Posted by tredegar
locate is excellent,
|
agreed, but the excellence of locate has always stopped me learning find properly, and locate only searches its database of filenames, so you can't do everything with it.
Quote:
If you get too much information, narrow it down with grep to select things in the /path/to/file that you think might apply. Eg:
Code:
locate .odt | grep Documents
|
in this case, it seems to be documents and not Documents, which makes me feel a bit smug (it won't last) about the fact that I would habitually do
Code:
locate .odt | grep -i Documents
without thinking. (Actually, that's a lie, what i'd do without thinking is
Code:
locate documents | grep -i .odt
or
Code:
locate documents | grep -i canadian | grep -i .odt
) (Ha! Lots of Irritating Single Parenthesise, beat that  )
|
|
|
|
07-12-2010, 10:16 PM
|
#7
|
|
Member
Registered: Jun 2007
Distribution: Debian Squeeze
Posts: 445
Original Poster
Rep:
|
Thanks for help.
I forgot about quoting:'*.odt'
I'll take a look at locate.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 05:40 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|