对文字字符串grep [英] Grep for literal strings

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

问题描述

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



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

您可以使用grep作为它,并带-F选项。

  -F,--fixed-strings PATTERN是一组换行分隔的固定字符串


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., []().*^$-\.

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

解决方案

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天全站免登陆