Tail具有以下选项:
-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.
我只想在尾部输出中为something设置grep。
tail -f <FILE>
我有以下几个非常好用的。
#!/bin/bash
killall java
#program USB
make iris install.1 mib510,/dev/ttyUSB0
#listen serial port and write to file
java net.tinyos.tools.PrintfClient -comm serial@/dev/ttyUSB1:iris > foo.txt &
sleep 2
#if "Erase done" is printed to file, stop
if tail -f foo.txt | grep -
我有一个日志文件,其中不断写入新的行。 我想要一个bash脚本,它可以连续读取这个日志文件的最后一行,这样我就可以处理该行(例如,如果该行包含单词“error”,则执行特定的命令)。 我试过了: while true
do
if tail -n1 -f file.log | grep -q ERROR
then
echo "$(date) : ERROR detected"
fi
done 但这是垃圾邮件: sun 21 mar 2021 18:32:41 CET : ERROR detected
sun 21 mar 2021 18: