LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 04-08-2007, 08:54 PM   #1
overlook1977
Member
 
Registered: Apr 2007
Location: North Carolina, USA
Distribution: Fedora 15
Posts: 68

Rep: Reputation: 15
How to search all directories for a file in bash


I know I can search with the KDE search function, but how would I search for a file if I did not know what directory it was located in? I was looking for 'xorg.conf'. I went into bash and typed 'whereis xorg.conf' but it returned "xorg". The file turned out to be in 'etc/X11'. I guess a bash command that would open the lost file would work, but is there a way to get bash to tell you the full path?
 
Old 04-08-2007, 08:57 PM   #2
cgjones
Member
 
Registered: Nov 2005
Location: Central New York
Distribution: Ubuntu
Posts: 405

Rep: Reputation: 30
Code:
find / -type f -iname xorg.conf
You might want to do this as root, otherwise you'll get a bunch of "Permission denied" errors.
 
Old 04-08-2007, 09:28 PM   #3
SlowCoder
Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934

Rep: Reputation: 38
For your instance, try 'locate xorg.conf'.
 
Old 04-08-2007, 09:29 PM   #4
overlook1977
Member
 
Registered: Apr 2007
Location: North Carolina, USA
Distribution: Fedora 15
Posts: 68

Original Poster
Rep: Reputation: 15
thanks! is there a way to force the shell to stop searching? this would be done by using ctrl-break in Windows, is there an equivalent?
 
Old 04-08-2007, 09:33 PM   #5
cgjones
Member
 
Registered: Nov 2005
Location: Central New York
Distribution: Ubuntu
Posts: 405

Rep: Reputation: 30
Ctrl-c should terminate the search.
 
Old 04-09-2007, 09:35 AM   #6
SlowCoder
Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934

Rep: Reputation: 38
The locate command uses a database catalog that is rebuilt nightly. Unless your files are newer than a day or so, you should be able to use locate. It is much faster than the find command. Find is great for finding files that have been newly added.
 
Old 04-09-2007, 12:15 PM   #7
MoMule
Member
 
Registered: Jul 2006
Posts: 134

Rep: Reputation: 15
type:

updatebd
# followed by
locate <file being searched>

The updatedb command will update the database immediately.

Deion "Mule" Christopher
 
Old 04-10-2007, 07:00 AM   #8
bandwidthjunkie
LQ Newbie
 
Registered: Jan 2007
Location: london
Distribution: Gentoo(amd64) - 2.16.20
Posts: 26

Rep: Reputation: 15
I would have thought that with slackware you would need to add
Code:
updatedb
to the daily cron run (the script needs root permissions) http://www.unixgeeks.org/security/ne...ix/cron-1.html. Then you can run
Code:
slocate blah
to find all instances of blah on your box. I find a useful search if I am looking for a program is
Code:
slocate blah | grep bin
This weeds out all the other rubbish and gives me what I'm looking for.
 
  


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
Does anyone know of a bash script can search & replace txt in a file. jimwelc Linux - Newbie 6 09-15-2008 12:13 AM
search a file for a word - bash script paul_mat Linux - Software 12 04-16-2006 01:59 AM
how to search for and delete empty directories? BrianK Programming 4 06-03-2005 07:24 AM
Using Grep to search all sub-directories yrraja Solaris / OpenSolaris 2 08-28-2004 03:29 AM
How to reconfigure GCC search directories jsmerritt Linux - Software 0 08-20-2004 10:59 AM


All times are GMT -5. The time now is 07:03 PM.

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