尾巴有以下select:
-f The -f option causes tail to not stop when end of file is reached, but rather to wait for additional data to be appended to the input. The -f option is ignored if the standard input is a pipe, but not if it is a FIFO.
我只想grep的something
在尾巴输出。
tail -f <FILE> | grep <SOMETHING>
问题是它只运行一次grep并完成。 没有其他输出发生。 我怎样才能使grep与-f
正确运行?
你会发现另一个SO问题有帮助: 如何“grep”连续流?
打开grep的行缓冲模式。
tail -f file | grep --line-buffered my_pattern
如果这是一个日志文件,它可能会旋转。 它会停止提供数据。
如果文件被旋转,这将不会停止。
tail --follow=name /var/log/syslog | grep "some data"