string=$(kubectl get pods -n $1 -o wide| grep abi-cloud-qr-platform-service | awk '{print$1}') #$1 环境 #$2 倒数2000行 #$3 搜索关键字 #$4 关键字上下多少行 if [ $3 ] ; then kubectl logs --tail $2 -f $string -n $1|grep -$4 --color=auto $3 else kubectl logs --tail 2000 -f $string -n $1 fi