linux命令——grep

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux命令——grep相关的知识,希望对你有一定的参考价值。

    在上一个命令中,我们知道可以使用cat来查看文本文件的内容,但是有的时候我们不是需要查看全部内容,而是需要查看包含某些信息的一行,如在渗透中我们需要查看某些配置文件中是否包含一些敏感信息,如密码信息,数据库连接信息等,就可以通过使用grep来进行快速查看我们需要查看的内容了!

使用语法如下:

grep 查找内容 要查找内容的文件

    如果查找内容中包含空格,那么需要加单引号‘,如:grep ‘test hh‘ filenema,另外可以在多个文件中进行查找,直接在后面继续添加文件名即可!

[email protected]:~/linuxcmd# grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
[email protected]:~/linuxcmd#
[email protected]:~/linuxcmd# grep root /etc/passwd /etc/shadow
/etc/passwd:root:x:0:0:root:/root:/bin/bash
/etc/shadow:root:$6$8uR2a64J$y2Oc5C6QsTRtJ1tpfpJKDIAfXzSM8rJ0IizfM32Mn.ac.UBUGgtq1HT2kgvnx4LFGukbj/poLJzg32VjpTbJS.:17103:0:99999:7:::
[email protected]:~/linuxcmd#


本文出自 “eth10” 博客,请务必保留此出处http://eth10.blog.51cto.com/13143704/1955922

以上是关于linux命令——grep的主要内容,如果未能解决你的问题,请参考以下文章

linux脚本中的ps等命令问题

写代码怎能不会这些Linux命令?

linux grep查询结果再过滤

linux grep命令详解

#grep ‘Linux’ filename命令查找的是啥文件?

linux 命令grep