a life of coding

Monday, April 11, 2005

Pearls of Unix

Sometimes, you really need to find something in a type of file. Grep -r is often too slow because of other large files in the same directory as your source. Here's one solution to the problem:

find . \( -iname '*.c' -or -iname '*.cpp' -or -iname '*.h' \) -exec grep -H searchstringhere {} \;

This will limit your search to .c, .cpp, and .h while still showing the filename of any matches (grep's -H option). Unfortunately, Windows has heavy processes that take much much longer to spawn than *nix... Since each found file spawns a grep process, this optimization might not save you any time under Cygwin.

2 Comments:

Post a Comment



<$I18N$LinksToThisPost>:

Create a Link

<< Home