Pages

Tuesday, March 6, 2012

How to search a word in multiple files

1. Search a word in all the files with the .txt extension in current directory.

 grep -H "word" *.txt

2. Search a word in all the files in current directory and its subdirectories. 

grep -H -r "word" home/directory

-H = display the name of the file
-r = search recursively trough subdirectories

0 comments:

Post a Comment