Tuesday, April 30, 2013

grep recursively to search from specific file type


grep -r --include=<pattern> <string> <directory>

grep -r --include=*.nk "Shot200" .

The above code will search any .nk files that contain the word 'Shot200' in the current folder and its subfolders recursively .

or use 'find'

find . -name "*.nk" -exec grep "Shot200" {} +

or 

find . -name "*.nk" | xargs grep "Shot200"