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

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

问题描述

是否可以使用NO regex来grep(或使用其他命令)查找确切的字符串?

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'lots\of"invalid"chars/and.triggers$(#2)[*~.old][3].html

我不想经历并逃避每一个逃脱"的事情.本质上,我想像通过echo一样通过它:

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'lots\of\"invalid\"chars/and.triggers$(#2)[*~.old][3].html"
/some/file"that/has'lots\of"invalid"chars/and.triggers$(#2)[*~.old][3].html

推荐答案

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

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

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

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