热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

是否可以组合使用尾部和grep?[重复]-Isitpossibletousetailandgrepincombination?[duplicate]

Thisquestionalreadyhasananswerhere:这个问题在这里已有答案:Howtogrepacontinuousstream?

This question already has an answer here:

这个问题在这里已有答案:

  • How to 'grep' a continuous stream? 10 answers
  • 如何'grep'连续流? 10个答案

I am trying to tail a user in production log.

我试图在生产日志中尾随用户。

Is it possible to use

是否可以使用

tail -f grep "username"

4 个解决方案

#1


12  

Yes - You use pipe. i.e.

是的 - 你使用烟斗。即

tail -f  | grep 'username'

#2


4  

Yes, you can just use a pipe

是的,你可以使用管道

tail -f fileName | grep username

tail -f fileName | grep用户名

#3


3  

The ack command, which is a grep-like text finder, has a --passthru flag that is designed specifically for this.

ack命令是一个类似grep的文本查找器,它有一个专门为此设计的--passthru标志。

Since ack automatically color codes matches for you, you can use it to search the output of a tailed log file, and highlight the matches, but also see the lines that don't match.

由于ack自动为您的颜色代码匹配,您可以使用它来搜索有尾日志文件的输出,并突出显示匹配,但也可以看到不匹配的行。

tail -f error.log | ack --passthru whatever

All the lines of the tailed log will show up, but the matches will be highlighted.

将显示有尾日志的所有行,但会突出显示匹配项。

ack is at http://beyondgrep.com/

ack在http://beyondgrep.com/

#4


1  

factually I have found it to be more efficient to use: grep username filename | tail

事实上我发现使用它更有效:grep username filename |尾巴


推荐阅读
author-avatar
齐cC含低
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有