You are visiting an archived page!

Computing Pages

by Francesc Hervada-Sala

cfind — search in C source files

cfind searches all C source files in a directory and its subdirectories for a given string.

cfind can distiguish some parts of the source code (declarations, preprocessor directives, remarks, parameters, function bodies) and one can restrict the search to some of these. It can also distinguish some compound words and search for whole words or word parts.

cfind is free software under the GNU General Public License.

Download: cfind-1.0.tar.gz


cfind <target> [options]


-d or —directory, directory (or single file) to search into

-e or —extensions, file extensions to be searched

-i or —case-insensitive, matching is case insensitive

-w or —whole-word match whole words

-p or —word-part, match word parts

-W or —string, ignore word bounds

-m or —match-all, ignore target string

--prep search in preprocessor directives

--decl search in variable and function declarations

--param search in function call parameters

--body search in function and variable bodies

--rem search in remarks

--lit search in literal strings

-a or —all-parts, search in all parts

-f or —file-inline, output file name

-F or —no-file-inline, do not output file name

-n or —line-number, output line number

-N or —no-line-number, do not output line number

-s or —summary, output match summary

-S or —no-summary, do not output summary

-t or —target, string to search for

-V or —version, print cfind version number and quit


To search in the current working directory and subdirectories all .c and .h files for functions, variables or macro definitions of the identifier "begin":

cfind begin

To exclude functions such as "begin123" or "begin_" from the matches:

cfind begin --whole-word

These searches will output all declarations, but not the calls to these functions or variables. To see just where they are called:

cfind begin --body

To search for the exact word "begin" in source code comments

cfind begin --rem
Print Contact

Version 1.0, October 2010