Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 04-30-2004, 04:39 PM   #1
Registered: Sep 2003
Location: Chicago
Distribution: Ubuntu
Posts: 36

Rep: Reputation: 15
ls -R {filename} How do I search for a single file?

Somethings I can do on Linux and still some simple stuff illudes me.
I can write a perl program, have it create an entry into a MySQL database and then have the same perl file e-mail a confirmation back to the user, but I still cannot find a simple file on the server.

In Perl I am told that I need to edit my file with the smtp server or I am going to have to put my smtp server entry in every file. I would rather just edit my file.

Only problem is, I can't find the darn thing. I've tried 'ls -R' but apparently that is not the correct way to use ls

MY REAL PROBLEM (enough venting now) : If someone could just PLEASE answer a simple question of how to do a recursive file find. Something similar to a dos 'dir/s filename.txt'

Thank you in advance for answering probably the stupidest question of the day. I already feel like a DOLT for having to resort to asking.
Old 04-30-2004, 04:40 PM   #2
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 67
If you have slocate installed:

find / -name
Old 04-30-2004, 06:31 PM   #3
Senior Member
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
maybe use grep with ls also?
Old 04-30-2004, 11:38 PM   #4
LQ Veteran
Registered: Mar 2003
Location: Boise, ID
Distribution: Mint
Posts: 6,642

Rep: Reputation: 85
I suppose if you want to use grep you could, but david_ross' answer solves the problem. To expand on his answer to make it a little more generic, you could run either:

slocate <search-string>


find <path> -name <search-string>

where <search-string> is what you're interested in finding and <path> is the directory from which you want to start searching. (Note that you shouldn't use wildcards in the search-string with slocate, but that you could/should use wildcards with find. Personally I think slocate is the way to go, assuming you've got it.) Lastly, if you use "find" as a regular user and you start searching from the top root directory, you are likely to get a lot of permission errors as a result of attempting to access directories that are off-limits. -- J.W.
Old 05-01-2004, 06:18 AM   #5
Senior Member
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
i never did like slocate, it requires to keep a database of my files, and i see that as a security risk (ok, more like I'm a lazy kid that don't want a stupid database of files because the FS is the database of files ..... and also i don't like running meaningless processes, find and ls work *slower no doubt* and better in my opinion)
Old 05-01-2004, 08:45 AM   #6
Registered: Mar 2004
Distribution: Slackware current, DSL 0.9.2
Posts: 133

Rep: Reputation: 15
find <path> -name <pattern> -print 2>/dev/null
much better
Old 05-01-2004, 10:06 AM   #7
Registered: Apr 2004
Location: Florida
Distribution: RedHat 9.0/Afterstep
Posts: 103

Rep: Reputation: 15
if you decide to use slocate (in RedHat you can just use
locate), make sure you have run updatedb first


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
change uploaded files from filename.avi to filename.avi.html like latheesan Linux - Newbie 3 06-16-2005 05:33 AM
emacs #filename# file question Guvvy Linux - Newbie 3 01-31-2005 07:26 PM
Find File broken, need search utility, where does WineX install, KDE file roller? Ohmn Mandriva 6 07-05-2004 11:34 PM
How to 'apt-cache search' & 'apt-file search' by distribution? davidas Debian 3 04-19-2004 02:56 PM
trying to search and replace text file for single & multiple line breaks separately brokenfeet Programming 7 08-29-2003 02:56 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:34 AM.

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