![]() |
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 Mail::Sendmail.pm 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 Sendmail.pm file. Only problem is, I can't find the darn thing. I've tried 'ls -R Sendmail.pm' 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. :cry: |
If you have slocate installed:
locate Sendmail.pm Otherwise: find / -name Sendmail.pm |
maybe use grep with ls also?
|
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> --or-- 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. |
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)
|
find <path> -name <pattern> -print 2>/dev/null
much better :) |
if you decide to use slocate (in RedHat you can just use
locate), make sure you have run updatedb first |
All times are GMT -5. The time now is 08:48 PM. |