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

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

问题描述

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

I am using the following command to grep stuff in subdirs

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

然而,这也会找到诸如 <s:textfield name="sdfsf"...../>

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

我能做些什么来避免这种情况,所以它只会找到像 <s:text name="sdfsdf"/>

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

OR 对于那个问题....也可以找到 <s:text somethingElse="lkjkj" name="lkkj"

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

基本上 s:textname 应该在同一行....

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

推荐答案

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

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

找到.|xargs grep -sw 's:text'

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

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