unixgrepexact-match

How to grep for the whole word


I am using the following command to grep stuff in subdirs

find . | xargs grep -s 's:text'

However, this also finds stuff like <s:textfield name="sdfsf"...../>

What can I do to avoid that so it just finds stuff like <s:text name="sdfsdf"/>

OR for that matter....also finds <s:text somethingElse="lkjkj" name="lkkj"

basically s:text and name should be on same line....


Solution

  • You want the -w option to specify that it's the end of a word.

    find . | xargs grep -sw 's:text'