尾部多个文件并grep输出 [英] tail multiple files and grep the output

查看:410
本文介绍了尾部多个文件并grep输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从多个进程不断更新的多个日志文件中提取一个模式,并连续跟踪该grep的输出. 下面的命令不起作用,我得到

I would like to grep a pattern from multiple log files which are being constantly updated by some processes and tail the output of this grep continuosly. Below command doesnt work and I get

  • 尾巴:警告:无限期遵循标准输入无效
  • tail: warning: following standard input indefinitely is ineffective

tail -f  | grep --line-buffered "Search this: " /var/links/proc2/id/myprocess*/Daily/myprocess*.log

有人可以帮忙解决这个问题吗?

Can someone help sort this out?

推荐答案

您应该看看 multitail 工具(使用sudo apt-get install multitail安装)

简而言之,对于多尾,您需要使用--mergeall标志在一个地方查看所有输出

In short, with multitail, you need to use the --mergeall flag for viewing output of all in one place

multitail --mergeall /var/links/proc2/id/myprocess*/Daily/myprocess*.log  | grep --line-buffered "Search this: " 

您可以在不使用grep的情况下执行相同的操作

You can do the same without using grep

multitail -E "Search this: " --mergeall /var/links/proc2/id/myprocess*/Daily/myprocess*.log  

要使用multitail单独查看输出,这还将提供文件名.

To view the output individually using multitail, this will give the filename as well.

multitail -E "Search this: " /var/links/proc2/id/myprocess*/Daily/myprocess*.log 

这篇关于尾部多个文件并grep输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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