awk gsub记

gsub字符串处理支持正则表达式

gsub(正则表达式, 要替换字符串, 待处理的字符串) 如 :

日志:
34.525: [GC (Allocation Failure) 34.525: [ParNew: 878871K->40833K(943744K), 0.0282753 secs] 878871K->40833K(3040896K), 0.0283802 secs] [Times: user=0.17 sys=0.01, real=0.03 secs]

// gc日志ygc,替换k->()字符为空串
cat gc1 | grep "ParNew"| awk -F ']' '{print $2}' | awk -F ',' '{gsub(/[K\->\(\)]/," ",$1);gsub(/[secs]/," ",$2); print $1,$2}'

 

你可能感兴趣的:(awk,gsub,Linux)