Path: Common/FileUtils

   Find all files that contain a specified string.
   [files,lineNums,lines] = FindInFiles( string,caseSensitive,wholeWord, 
                                               includeComments, fileSet );

   string           (:)      Text string to search for.
                                Note: If no string is provided, or if '' is provided, the
                                      function will return the entire searchable file set.
                                (Optinal. Default is '')

   caseSensitive    (1)      Flag indicating whether the search should be case sensitive
                                (Optional. Default is NOT case sensitive, 0)

   wholeWord        (1)      Flag indicating whether to search for only the whole word or not
                                (Optional. Default is NOT to constrain search to whole word, 0)

   includeComments  (1)      Flag indicating whether to include comments in the search
                                0 - do NOT include comments in the search
                                1 - INCLUDE comments in the search (no restriction)
                                2 - allow ONLY comments to be included in the search
                                Note: If a "%" symbol appears before the first instance of
                                      the string in a line, the line is considered a comment.
                                (Optional. Default is to INCLUDE comments in the search, 1)

   fileSet          {:}      The searchable file/folder set. This is a cell array of file and/or
                             folder names to search over. Either the full file/folder name 
                             (directory path prepended) or the partial name may be used.
                             Whenever listing files, the file extension MUST be included.
                                Note: If only a partial filename is provided, the file that
                                appears FIRST in the Matlab search path will be used.
                                (Optional. Default is to search over all m-files in the path)

   files           {N,1}        Cell array list of all "N" files containing the string
                                   (subject to case sensitivity and comment inclusion constraints)

   lineNums        {1,N}(1,M)   Cell array of "N" vectors. Each vector is a list of line numbers
                                where the string was found.
                                   Note: If no string is supplied, this output is just {}

   lines           {1,N}{1,M}   Cell array of "N" cells, each containing "M" lines of text. 
                                Each line of text is an entire line found in the corresponding file 
                                that contains the string.
                                   Note: If no string is supplied, this output is just {}



Common: FileUtils/PathDirectories

Back to the Common Module page