search through text files

Sometimes, firing up an IDE’s to do source code search might be more wait than I am willing to go through. So, here is an one-line command that I used to search through a directory full of source code:

for i in `find . -name "*.java"`; do egrep -H -n "search_string" $i; done

You may wish to replace file pattern and search pattern text to fit your needs.

Advertisements

One thought on “search through text files

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s