Welcome 微信登录

首页 / 操作系统 / Linux / grep命令输出显示高亮字

grep命令执行后,终端上输出显示颜色可以加“--color=auto”的参数。另外的两个办法是:1.设置环境变量:export GREP_OPTIONS="--color=auto"2.修改.bashrc给grep起别名,用alias设置。我的这个系统其实已经写有,但是是注释掉的,现在把他打开,看到84行:84   alias grep="grep --color=auto"85   #alias fgrep="fgrep --color=auto"86   #alias egrep="egrep --color=auto"这样,在grep执行后的标准输出就会将匹配的文件标识为彩色。[root@mode etc]# grep allowed_host /usr/local/nagios/etc/nrpe.cfgallowed_hosts= 172.30.71.20如果你配置完之后没有效果:请修改下secureCRT设置:Location:Options->Global options->General->Default session->Edit Default Settings->Terminal->Appearance->Font选项-全局选项-常规-默认会话-编辑默认设置-仿真(终端设置为Linux并使用颜色方案)-外观(字体Lucida Console 10pt,字符编码UTF-8)设置完以后关闭当前会话,重新打开即可。----------------设置色彩选项-会话-终端-仿真-ANSI颜色(打勾即可) grep使用简明及正则表达式  http://www.linuxidc.com/Linux/2013-08/88534.htmLinux下Shell编程——grep命令的基本运用 http://www.linuxidc.com/Linux/2013-06/85525.htmgrep 命令详解及相关事例 http://www.linuxidc.com/Linux/2014-07/104041.htmLinux基础命令之grep详解 http://www.linuxidc.com/Linux/2013-07/87919.htm设置grep高亮显示匹配项 http://www.linuxidc.com/Linux/2014-09/106871.htmLinux grep命令学习与总结 http://www.linuxidc.com/Linux/2014-10/108112.htm本文永久更新链接地址