如何grep整个词 [英] How to grep for the whole word

查看:126
本文介绍了如何grep整个词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下命令来grep子目录中的内容

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

然而,这也可以找到像< s:textfield name =sdfsf..... />



我可以做些什么来避免这种情况只是找到像< s:text name =sdfsdf/>



或类似的东西。 ...也发现< s:text somethingElse =lkjkjname =lkkj



基本上 s:text name 应该位于同一行....

解决方案

您希望 -w 选项指定它是单词的结尾。 b

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


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

解决方案

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

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

这篇关于如何grep整个词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆