LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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

Reply
 
Search this Thread
Old 07-12-2010, 11:44 AM   #1
JosephS
Member
 
Registered: Jun 2007
Distribution: Debian Squeeze, CrunchBang Waldorf
Posts: 514

Rep: Reputation: 38
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
 
Old 07-12-2010, 12:19 PM   #2
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
You need to prevent the shell from expanding the *:
Code:
find -iname '*.odt'
 
Old 07-12-2010, 12:25 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
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.
 
Old 07-12-2010, 12:36 PM   #4
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,012

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
locate is excellent, and pre-installed on all the distros I've used. It's much faster than find
Code:
locate .odt
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)
Code:
updatedb
then run locate
 
Old 07-12-2010, 12:37 PM   #5
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
i think linux defaults to ., while bsd doesn't. best to always specify the path, as pixellany says.
 
Old 07-12-2010, 04:39 PM   #6
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 3,902

Rep: Reputation: 775Reputation: 775Reputation: 775Reputation: 775Reputation: 775Reputation: 775Reputation: 775
Quote:
Originally Posted by tredegar View Post
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 )
 
Old 07-12-2010, 10:16 PM   #7
JosephS
Member
 
Registered: Jun 2007
Distribution: Debian Squeeze, CrunchBang Waldorf
Posts: 514

Original Poster
Rep: Reputation: 38
Thanks for help.
I forgot about quoting:'*.odt'
I'll take a look at locate.
 
  


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
[SOLVED] command to find a specific word in directories and subdirectories? siranjeevi Linux - Newbie 4 06-09-2010 09:19 AM
searching a file in subdirectories with ls visitnag Linux - Newbie 4 04-23-2009 11:45 AM
Using Bash, Find script files in a directory or subdirectories within... ray5_83 Programming 4 10-10-2008 07:42 PM
Find files in current directory, not subdirectories SmurfGGM Linux - Newbie 1 10-09-2008 12:14 PM
Evolution can't find libs in its own subdirectories slackist Linux - Software 3 03-16-2005 09:49 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration