Re: grep question


Subject: Re: grep question
From: Martin Sevior (msevior@mccubbin.ph.unimelb.edu.au)
Date: Sun Feb 27 2000 - 21:14:49 CST


You could just use some silly python hacks I've put together for exactly
this purpose.

I call this "loccp" for looking for specified strings within *.cpp files

#!/usr/bin/python
import string
import sys , os
val = sys.argv[1]
fs = '`find . -name "*.cpp"`'
gs = 'grep -i ' + val + ' ' + fs
print 'Executing.. \n ',gs
os.system(gs)

I also have loch (look in *.h files) and locc (for *.c files). These
little commands have been incredibally useful.
        
These search recursively from the current directory and do a case
insensitive search with the specified files. This is an extremely useful
way of stealing code from other parts of abi and to learn how different
functions and classes work.

Cheers

Martin

On Sun, 27 Feb 2000, Daniel Weber wrote:

> I want to search the source tree for certain strings, but only certain
> types of files (e.g. cpp or h files). grep has a --recursive option,
> but it doesn't allow you to specify a file extension with that option,
> so it searches all files, including the obj and binary files which takes
> forever. Is there a way to limit a grep search to an extension, or do I
> have to write a tiny shell script that does it? This is such a common
> thing to do, I'm sure I'm missing something....
>
> This is on linux, BTW.
>
>
>



This archive was generated by hypermail 2b25 : Sun Feb 27 2000 - 21:15:12 CST