LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 06-08-2004, 01:11 PM   #1
t3___
Member
 
Registered: Sep 2003
Posts: 240

Rep: Reputation: 30
simple search commands in linux


This seems like a terribly simple question, but I've searched the man pages and internet tutorials for ls, grep, and find and have ended up a little confused.

All I would like to do is be able to simple filesystem searches for filenames or part of a filename. I hate to equate things to windows, but in dos I would type:

c:\ dir /s foo*

to search the entire drive letter for anything beginning with "foo* (ex foo.exe, foobar.doc, fooztastic.jpg)

or:

c:\ dir /s *.avi

to search the entire drive letter for avi files...

Any help would be greatly appreciated.

T
 
Old 06-08-2004, 01:18 PM   #2
lyceum
Member
 
Registered: Aug 2003
Location: N.C.
Distribution: rh9, fc1, slack 9.1, 10
Posts: 229

Rep: Reputation: 30
look into the locate command.
 
Old 06-08-2004, 01:25 PM   #3
t3___
Member
 
Registered: Sep 2003
Posts: 240

Original Poster
Rep: Reputation: 30
but doesn't locate use an indexing/database function to handle searches... and don't you have to run updatedb or something to re-index for accurate search results?
 
Old 06-08-2004, 01:29 PM   #4
lyceum
Member
 
Registered: Aug 2003
Location: N.C.
Distribution: rh9, fc1, slack 9.1, 10
Posts: 229

Rep: Reputation: 30
yes, this is true, but i have updatedb to run as a periodic cron job.
 
Old 06-08-2004, 01:32 PM   #5
lyceum
Member
 
Registered: Aug 2003
Location: N.C.
Distribution: rh9, fc1, slack 9.1, 10
Posts: 229

Rep: Reputation: 30
here is a similar thread that gives instructions to set up the cron job.

hope this helps.
 
Old 06-08-2004, 01:35 PM   #6
t3___
Member
 
Registered: Sep 2003
Posts: 240

Original Poster
Rep: Reputation: 30
ah! good thinking - thanks for the info.
 
Old 06-08-2004, 02:16 PM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
The find command is one you will want to learn. You can find by pattern, owner, permissions, type of file, etc.

For your example:

find ~/ -name "foo*"

will find all files beginning with 'foo' in your home directory and subdirectories.

find /usr -cmin -10
will find all files created in the last 10 minutes in the /usr directory. This is handy to locate where files were installed that you just installed.

These are just two simple examples. You can combine tests also: find /usr -name "foo*" -cmin -60
 
  


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
simple search and replace accross files/direcotries podollb Linux - Software 3 06-04-2004 09:30 PM
Simple Commands jackel Linux - Newbie 3 04-14-2004 12:43 AM
Simple resolve.conf question (Search Command) rrosenkoetter Linux - Networking 2 04-05-2004 08:46 PM
basic linux commands... search? Mytherall Linux - Newbie 1 02-23-2004 07:52 AM
Linux commands - simple for some jmcmillan Linux - Newbie 4 06-10-2003 03:14 PM


All times are GMT -5. The time now is 04:46 PM.

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