Tee 和 Grep,多次过滤和附加脚本的输出

Tee and Grep, filtering and appending the output of a script several times

我有一个每 30 分钟输出一次日志的脚本,这些日志被附加到一个存储所有日志的文件中,然后我过滤包含“Maas”字符串的日志并将这些日志存储到另一个文件中。

(script output) | tee -a alldata.log | grep 'Maas' >> filterMaas.log

我需要做的是添加更多的过滤器输出到几个文件,以下行不起作用,文件 filterCCSA.log 是空的。

(script output) | tee -a alldata.log | grep 'Maas' >> filterMaas.log | grep 'CCSA' >> filterCCSA.log 

知道如何使这项工作有效吗?

你可以这样做:

(script output) | tee >(grep 'Maas' >> filterMaas.log) >(grep 'CCSA' >> filterCCSA.log)  >> alldata.log