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?
You should have a look at multitail
tool (Install using sudo apt-get install multitail
)
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: "
You can do the same without using grep
multitail -E "Search this: " --mergeall /var/links/proc2/id/myprocess*/Daily/myprocess*.log
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
the mistake is that you give the files to the grep command and not the tail.
the tail -f needs to get the files as input. try:
tail -f /var/links/proc2/id/myprocess*/Daily/myprocess*.log | grep --line-buffered "Search this: "
to get also the file names (however it will not be like grep output it is):
tail /var/links/proc2/id/myprocess*/Daily/myprocess*.log | grep --line-buffered -e'^==> .* <==$' -e'Search this: '
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With