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.
One thought on “search through text files”
You don’t even need find:
‘egrep -HInR –include=”*.java” “search_string” .’
(PS: And when using find, I’d rather use -exec action or xargs)