tags:

views:

24

answers:

2

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....

A: 

If you just want to filter out the remainder text part, you can do this.

xargs grep -s 's:text '

This should find only s:text instances with a space after the last t. If you need to find s:text instances that only have a name element, either pipe your results to another grep expression, or use regex to filter only the elements you need.

Stefan Kendall
+2  A: 

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

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

Zurahn