1748255 Members
4037 Online
108760 Solutions
New Discussion юеВ

Re: find in root

 
Dennis Handly
Acclaimed Contributor

Re: find in root

>any faster way of searching?

As HGH, JRF and Clay (Plan B) have suggested, you want to do one find, then grep with your list of files. Your original while/find would do N finds.

One advantage of Plan B is that you can look for a filename that wasn't in your "file".

 

> find / -xdev -type f -name myfile -o -name yourfile -o -name "her*" -o -name "his*"

 

If you are going to mix AND with OR, you need to use ():

# find / -xdev -type f \( -name myfile -o -name yourfile -o -name "her*" -o -name "his*" \)

Rasheed Tamton
Honored Contributor

Re: find in root

Hi,

You can add -type f (type is file, -d dir, etc.)
(find / -type f -name $FILENAME)
or even add -mtime -12 (within the last 12 days) or +12 (12 + days)
(find . -type f -mtime -1300 -name $FILENAME)

to make it faster the search operation.
Also see the -atime, -mtime and -user (owner of the file, etc to make your search faster.

See man find

Rasheed Tamton.
Steven Schweda
Honored Contributor

Re: find in root

> [...] i have to search in the whole
> filesystem (root /).

> Its not tat i want to search in root. I
> just gave an example.

Sometimes it's helpful to ask the question
for which you actually want the answer.

> cat file|while read FILENAME

Knowing, even approximately, what is in
"file" might also be helpful in deciding
which of the techniques already suggested
would be good or bad.