Let me recommend a few of Bai Yang's command-line search/replace tools. They're more powerful than CMD's built-in findstr, and also have some advantages over grep. Very useful. I saw them on CCF. Reposting them here as well.
http://www.baiy.cn/
1. Command-line tool f - search for matching strings in files
Feature summary
-----------------------------------------------------------
2. find - replace
fr - batch search and replace matching strings in files
Last updated: 2009-12-13, Ver 2.1.6.1213
* Supports specifying multiple file wildcards and file lists at one time.
* Supports pipe mode, working together with other commands; also supports semi-pipe mode, reading input from files but writing results to standard output.
* Supports including subdirectories.
* Supports ordinary matching, regular-expression matching, case-insensitive matching, and multi-line matching. Replacement can use regular-expression subexpressions.
* Supports TCL 8.2-compatible advanced regular expressions (ARE).
* Supports both POSIX standard extended regular expressions and Perl-style regular-expression matching.
* Can format replacement content as all uppercase or all lowercase, making it convenient in batch files to normalize the case of environment variables and command-line parameters.
* Supports DOS (Windows), Macintosh, and unix-style line endings, with optional automatic detection (default) or manual specification.
* Supports Win32 and pure DOS environments (pure DOS requires HX DOS Extender support).
* Supports POSIX environments, with versions available for linux x86/x64, FreeBSD, NetBSD, Solaris, etc.
------------------------------------------------------------
3. wide find - replace
wfr
- supports batch search and replacement of multilingual strings
- batch character-set encoding conversion
Last updated: 2009-12-13, Ver 2.3.6.1213
* A pure unicode rule-matching engine, truly supporting regular-expression matching for text in various languages.
* Supports TCL 8.2-compatible advanced regular expressions (ARE).
* Character-set encoding conversion with compatibility checking. Supports both GUN libiconv (iconv.dll) and the character-set conversion API built into Windows.
* Supports specifying multiple file wildcards and file lists at one time.
* Supports pipe mode, working together with other commands; also supports semi-pipe mode, reading input from files but writing results to standard output.
* Supports including subdirectories.
* Supports ordinary matching, regular-expression matching, case-insensitive matching, and multi-line matching. Replacement can use regular-expression subexpressions.
* Supports both POSIX standard extended regular expressions and Perl-style regular-expression matching.
* Can format replacement content as all uppercase or all lowercase, making it convenient in batch files to normalize the case of environment variables and command-line parameters.
* Supports DOS (Windows), Macintosh, and unix-style line endings, with optional automatic detection (default) or manual specification.
* Statistics function, listing the number of replacements in each file, total replacements, etc.
* Supports Win32 and pure DOS environments (pure DOS requires HX DOS Extender support).
* Supports POSIX environments, with versions available for linux x86/x64, FreeBSD, NetBSD, Solaris, etc.
There are some other command-line tools on the above homepage as well; everyone can look them up as needed.
http://www.baiy.cn/
1. Command-line tool f - search for matching strings in files
Feature summary
* Supports specifying multiple file wildcards and file lists at one time.
* Supports pipe mode, working together with other commands.
* Supports including subdirectories. Unlike grep, even if the search directory itself contains no matching files, it will still continue searching subdirectories.
* Supports ordinary matching, regular-expression matching, case-insensitive matching, and multi-line matching.
* Supports both POSIX standard extended regular expressions and Perl-style regular-expression matching.
* Supports DOS (Windows), Macintosh, and unix-style line endings, with optional automatic detection (default) or manual specification.
* Fully customizable output format for match results, making them easier to view or use together with other software.
* Statistics function, listing the number of matches in each file, total matches, etc.; it can also list only the files where matches were found.
* Supports Win32 and pure DOS environments (pure DOS requires HX DOS Extender support).
Typical uses
1. Use by itself on the command line, or as a pipe filter. For example: "expand -d *.cab | f -ric:g.*.(dll|exe)" searches all cab files in the current directory for dll or exe files beginning with g.
2. Used in batch files.
3. Used together with other tools. For example, in vim enter: ":set grepprg=f\ /o:F:l:o" and you can add batch matching capability to vim. Then use the vim command ":grep *.h *.c *.cpp *.hpp *.cxx /s /r:test.*string" to search all source files in the current directory and subdirectories. After that you can use the :cn command to jump to the next match; :cnf jumps to the first match in the next file, and so on.
Quote: Author: lyh728 sed sed also OP's tool, in what way is it stronger than grep?
Well, the feature summary already says it, hehe.
To sum it up, there are probably a few points:
1. When grep searches subdirectories, if the starting directory has no files matching the wildcard, the search stops and it will not check subdirectories. For example: grep -r -i 'test' *.cpp If there are no .cpp files in the current directory, but there are in subdirectories, grep will fail and won't search the subdirectories.
2. Multiple file wildcard support, so you can do this: f *.h *.cpp *.c *.txt /s .... grep seems unable to do that.
3. Some miscellaneous improvements, such as customizable output format and so on.
-----------------------------------------------------------
2. find - replace
fr - batch search and replace matching strings in files
Last updated: 2009-12-13, Ver 2.1.6.1213
* Supports specifying multiple file wildcards and file lists at one time.
* Supports pipe mode, working together with other commands; also supports semi-pipe mode, reading input from files but writing results to standard output.
* Supports including subdirectories.
* Supports ordinary matching, regular-expression matching, case-insensitive matching, and multi-line matching. Replacement can use regular-expression subexpressions.
* Supports TCL 8.2-compatible advanced regular expressions (ARE).
* Supports both POSIX standard extended regular expressions and Perl-style regular-expression matching.
* Can format replacement content as all uppercase or all lowercase, making it convenient in batch files to normalize the case of environment variables and command-line parameters.
* Supports DOS (Windows), Macintosh, and unix-style line endings, with optional automatic detection (default) or manual specification.
* Supports Win32 and pure DOS environments (pure DOS requires HX DOS Extender support).
* Supports POSIX environments, with versions available for linux x86/x64, FreeBSD, NetBSD, Solaris, etc.
------------------------------------------------------------
3. wide find - replace
wfr
- supports batch search and replacement of multilingual strings
- batch character-set encoding conversion
Last updated: 2009-12-13, Ver 2.3.6.1213
* A pure unicode rule-matching engine, truly supporting regular-expression matching for text in various languages.
* Supports TCL 8.2-compatible advanced regular expressions (ARE).
* Character-set encoding conversion with compatibility checking. Supports both GUN libiconv (iconv.dll) and the character-set conversion API built into Windows.
* Supports specifying multiple file wildcards and file lists at one time.
* Supports pipe mode, working together with other commands; also supports semi-pipe mode, reading input from files but writing results to standard output.
* Supports including subdirectories.
* Supports ordinary matching, regular-expression matching, case-insensitive matching, and multi-line matching. Replacement can use regular-expression subexpressions.
* Supports both POSIX standard extended regular expressions and Perl-style regular-expression matching.
* Can format replacement content as all uppercase or all lowercase, making it convenient in batch files to normalize the case of environment variables and command-line parameters.
* Supports DOS (Windows), Macintosh, and unix-style line endings, with optional automatic detection (default) or manual specification.
* Statistics function, listing the number of replacements in each file, total replacements, etc.
* Supports Win32 and pure DOS environments (pure DOS requires HX DOS Extender support).
* Supports POSIX environments, with versions available for linux x86/x64, FreeBSD, NetBSD, Solaris, etc.
There are some other command-line tools on the above homepage as well; everyone can look them up as needed.



