Linux为STDOUT的关键字设置颜色

原理

echo "颜色测试aaa实测" | perl -pe 's/(aaa|实|测)/e[1;31m$1e[0m/g' 

实战

用于过滤debug日志并显示出关键字:

tail -f app_debug.log | grep -vEi 'org.springframework.session.data.redis.w|org.springframework.data.redis.core.w|io.lettuce.core.protocol.w|org.mongodb.driver.cluster|org.mongodb.driver.protocol.command|org.mybatis.spring.SqlSessionUtils|org.apache.http.impl.conn.PoolingHttpClientConnectionManager' | perl -pe 's/(select|update|insert|Preparing:| Parameters: | from|join)/e[1;31m$1e[0m/g'
原文地址:https://www.cnblogs.com/testopsfeng/p/13213589.html