codegirl42

Well-Known Member
Mar 9, 2006
93
0
156
Is there an easy way to search the root for files with a certain prefix?

Like....say I'm looking for a hack.... that has a file named blahblah.html

How can i search the server for it?
 

levelsupport

Well-Known Member
Oct 7, 2006
47
0
156
if you want to search in user home directories use this

find /home/* | grep xyz
here xyz is the name you want to search
 

sparek-3

Well-Known Member
Aug 10, 2002
1,983
218
343
cPanel Access Level
Root Administrator
grep is used to search the contents of a file for a strong (or the output of command if used with a pipe).

find is used to find files on the server.

locate is a lot like find, except it depends on an updatedb process running and indexing files on your server. If updatedb is not being run, then locate will not be useful. locate is also bound to files that were last indexed by updatedb. So if updatedb runs at 5AM and a file is added at 10AM, then if you run locate file at 2PM, the file added at 10AM will not show up.

Basically to search for a particular file with a particular file extension, you would want to use find

find -name \*\.html

This will search for all .html files in the current directory and all directories underneath the current directory. You can further manage how far to search in a directory by using the -maxdepth and -mindepth options. A lot of information for find can be found in its man page man find