如何 grep 精确的文字字符串(无正则表达式) [英] How to grep exact literal string (no regex)

查看:27
本文介绍了如何 grep 精确的文字字符串(无正则表达式)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法grep(或使用另一个命令)来查找确切的字符串,而不使用正则表达式?

例如,如果我想搜索(字面意思):

/some/file"that/has'lotsof"invalid"chars/and.triggers$(#2)[*~.old][3].html

我不想经历并逃脱每一个可逃脱的".本质上,我想通过它,就像使用 echo 一样:

$ echo "/some/file"that/has'lotsof"invalid"chars/and.triggers$(#2)[*~.old][3].html"/some/file"that/has'lotsof"invalid"chars/and.triggers$(#2)[*~.old][3].html

解决方案

使用fgrep,与grep -F相同(匹配固定字符串).

Is there a way to grep (or use another command) to find exact strings, using NO regex?

For example, if I want to search for (literally):

/some/file"that/has'lotsof"invalid"chars/and.triggers$(#2)[*~.old][3].html

I don't want to go through and escape every single "escapable". Essentially, I want to pass it through, like I would with echo:

$ echo "/some/file"that/has'lotsof"invalid"chars/and.triggers$(#2)[*~.old][3].html"
/some/file"that/has'lotsof"invalid"chars/and.triggers$(#2)[*~.old][3].html

解决方案

Use fgrep, it's the same as grep -F (matches a fixed string).

这篇关于如何 grep 精确的文字字符串(无正则表达式)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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