我有一个关于如果日志文件中有特定文本则执行命令的问题。已经有文章了:https://unix.stackexchange.com/questions/12075/best-way-to-follow-a-log-and-execute-a-command-when-some-text-appears-in -the-log。所以我的问题是:是否可以对一个包含的文本做一件事,而对另一文本做其他事情?
我当前的代码是:
tail -F ~/server/logs/current.log | grep --line-buffered " was stopped. Please stop to prevent Server crashes" | while read; do killall java; done
亲切的问候,
图蒂鸟