Monday, February 9, 2009

Linux Unix Find in Files

Following command will search string in files in the directories and sub-directories under current directory.

find . -exec grep "String to be searched" '{}' \; -print

Following command will search string in files which names matches certain criteria.

find . -name '*.html' -exec grep 'String to be searched' {} \; -print

Handy about these is it will print the line containing the file and also file name with path from current directory.

Njoi
Thiru

No comments:

Post a Comment