用于文字字符串的 Grep [英] Grep for literal strings

查看:26
本文介绍了用于文字字符串的 Grep的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 grep 类型的工具来搜索纯文字字符串.我正在寻找日志文件的一行出现,作为单独日志文件中一行的一部分.搜索文本可以包含各种正则表达式特殊字符,例如,[]().*^$-.

I'm after a grep-type tool to search for purely literal strings. I'm looking for the occurrence of a line of a log file, as part of a line in a seperate log file. The search text can contain all sorts of regex special characters, e.g., []().*^$-.

是否有一个 Unix 搜索实用程序不会使用正则表达式,而只是搜索字符串的字面出现?

Is there a Unix search utility which would not use regex, but just search for literal occurrences of a string?

推荐答案

您可以使用带有 -F 选项的 grep.

You can use grep for that, with the -F option.

-F, --fixed-strings       PATTERN is a set of newline-separated fixed strings

这篇关于用于文字字符串的 Grep的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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