digitalmars.com                        
Last update Sun Sep 8 21:42:01 2013

GREP: Search Files for Pattern

grep is used to search for strings in multiple files. Digital Mars grep is handy because it's fast, will search system and hidden files, will search for wide characters strings, and will search binary files.

Command syntax:

grep [switches] pattern { file }
pattern
the string to search for.
file
the name of the file to search. Multiple files can be listed, and wildcards can be used.
-h
Suppress printing of filenames.
-i
Become case-insensitive.
-r
Recursively search subdirectories.
-v
Verbose; print name of each subdirectory as it is searched.
-z
Search for wide character strings.

grep will print each line in each file that contains a match for pattern. It works with binary files as well as text files.

Example:

To search all .c files for the string 'this':

grep this *.c

To find which library file is the one to link for FindFirstFile():

grep -i findfirstfile \dm\lib\*.*
Home | Runtime Library | IDDE Reference | STL | Search | Download | Forums