Shell Linux: Is it possible to speed up the file search using & ldquo; Find & rdquo; Using a predefined list of files / folders?


I primarily program in Linux, using tcsh shell. By default, my current directory is the root of my code base - I use "find" to locate whichever file I'm interested in modifying, and then once find shows up the location of the file, I can then edit/modify on Vim.

The problem is, due to the size of the code base, every time I ask find to show up the location of a file , it takes at least 4-5 seconds to complete the search, which are too short to be used for anything else !! So, since the rate is new files being added to the code base is very small, i'm looking for a way as follows:

1) Generate the list of all files in my code base

2) Have find look in only those locations/files to answer my query

I've seen how opening up files in cscope is lightning fast, as it stores the list of files previously. I'd like to use the same mechanism for find, just not from within the cscope window, but from the generic cmd line.

Any ideas ?

You could write a list of directories to a file and use them in your find command:

$ find /path/to/src -type d > dirs
$ find $(cat dirs) -type f -name "foo"

Alternatively, write a list of files to a file and use grep on it. The list of files is more likely to change than the list of dirs though.

$ find /path/to/src -type f > files
$ vi $(grep foo files)