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.

Advertisement

One thought on “search through text files

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

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

Facebook photo

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

Connecting to %s