如何在linux中查找包含字符串的行 [英] How to find lines containing a string in linux

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

问题描述

我在 Linux 中有一个文件,我想在该文件中显示包含特定字符串的行,该怎么做?

I have a file in Linux, I would like to diplay lines which contain a specific string in that file, how to do this?

推荐答案

通常的方法是使用 grep,它使用一个 匹配行的模式:

The usual way to do this is with grep, which uses a regex pattern to match lines:

grep 'pattern' file

匹配模式的每一行都会被输出.如果只想搜索固定字符串,请使用 grep -F 'pattern' file.

Each line which matches the pattern will be output. If you want to search for fixed strings only, use grep -F 'pattern' file.

这篇关于如何在linux中查找包含字符串的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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