Tee和Grep,多次过滤并附加脚本的输出[重复]

问题描述 投票:0回答:1
我有一个脚本,每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

知道如何使这项工作有效吗?
linux bash grep tee
1个回答
1
投票
您可以做这样的事情:

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

© www.soinside.com 2019 - 2024. All rights reserved.