I would like to use Zgrep and Awk to print specific lines.
I use the below script. However, I am not able to print the specific line requirement.
zcat SYS.20210519.tgz | awk '/11055/ && /2.5.5.5/'
It would be nice if someone could help. Thanks.
File name : SYS.20210519.tgz
File INPUT :
20210519 072532 11055 ERROR Connection is not writable, error[grpId[2.5.5.5/49.3.14.13:17126] connId[142706130] testMode[true] connInfo[ConnInfo[connId=142706130, connGrp=2.5.5.5/49.3.14.13:17126,
File output (Needed) :
20210519 072532 11055 ERROR Connection is not writable, error[grpId[2.5.5.5/49.3.14.13:17126]
With your shown samples, could you please try following. Using zcat
to read your Input_file then sending its output as standard input to awk
program. Where using match
function to match regex, which will print till value of error[grpId till ]
occurrence.
zcat Input_file |
awk 'match($0,/.*error\[grpId\[[^]]*\]/){print substr($0,RSTART,RLENGTH)}'