Reputation: 51
How to grep single word in different directory and file name is also same in different directory.
Upvotes: 5
Views: 8325
Reputation: 265271
If you are using bash you can use the following:
grep 'pattern' {dir1,dir2,dir3}/filename
Upvotes: 4
Reputation: 31655
Specify each file as an argument:
grep -w vwhat /some/file /another/file /a/third/file
Upvotes: 2
Reputation: 1
I'm not sure to understand what you want.
Can't you just run
grep -rwn word /some/dir1/ /other/dir2/
Read the GNU grep documentation!
Upvotes: 7