Monday, January 08, 2007

Find files with text in UNIX

Finds all java files that contain text "Canada":

find . -name "*java" -exec grep "Canada" '{}' \; -print

Notes:
'{}' is substituted by the current file name
'-print' outputs the matching filename

2 comments:

Big 40wt Svetlyak said...

find . --name '*.java' | xargs grep Blah

Big 40wt Svetlyak said...

I'm sorry, -name of cause.