Showing posts with label grep. Show all posts
Showing posts with label grep. Show all posts

Wednesday, March 07, 2007

How to ignore .svn directories in grep?

This has bothered me for a while. A google search shows two popular implementations to work around this: using grep's --exclude parameter or use find to filter out the hidden directories. I chose the --exclude parameter approach since it is pretty neat and easy to integrate into my own bash environment by defining an alias.

Here is the alias definition in my ~/.bash_profile

alias g="egrep --exclude=\*.svn\* -r -n "

Tuesday, December 19, 2006

Goal: to see a python file code structure from command line.
 egrep 'def |class ' {python file}

The grep comes with cygwin seems to have problem with this:

 grep 'def |class ' web.py

but egrep works fine. Seems like 'def |class ' is not supported by standard regular expression. Or put it in another way, it's part of the extended regular expression set.

This article gives a good quick overview on grep, fgrep, and egrep.