linux使用grep查找文件内容,Linux中使用grep命令搜索文件名及文件内容的方法

您所在的位置:网站首页 搜索文件内容linux linux使用grep查找文件内容,Linux中使用grep命令搜索文件名及文件内容的方法

linux使用grep查找文件内容,Linux中使用grep命令搜索文件名及文件内容的方法

2023-09-16 06:52| 来源: 网络整理| 查看: 265

这篇文章主要介绍了Linux中使用grep命令搜索文件名及文件内容的方法,同时文中还介绍了将匹配结果高亮显示的方法,相当实用,需要的朋友可以参考下

从文件中搜索并显示文件名

当从多个文件中搜索时,默认将显示文件名:

$grep "word" 文件名

$ grep root /etc/*

示例输出:

/etc/bash.bashrc: See "man sudo_root" for details.

/etc/crontab:17 * * * * root cd / && run-parts --report /etc/cron.hourly

/etc/crontab:25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

/etc/crontab:47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )

/etc/crontab:52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )

/etc/group:root:x:0:

grep: /etc/gshadow: Permission denied

/etc/logrotate.conf: create 0664 root utmp

/etc/logrotate.conf: create 0660 root utmp

每行开始的第一个部分是文件名(如:



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3