比如反向引用的例子,
原日志如下:
{"accessip_list":"120.194.227.182","client_ip":"120.194.227.188","@timestamp":"2019-11-13T21:36:11+08:00","method":"GET","url":"/cateory/index.php","status":"200","body_bytes_sent":"1008570","request_time":"1.268","http_user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36","total_bytes_sent":"1031523"}
将accessip_list的ip赋值给client_ip,达到一致性
那么在sed命令中使用如下:
sed -i 's#{"accessip_list":"(.*)","client_ip":".*","@timestamp"#{"accessip_list":"1","client_ip":"1","@timestamp"#g' 1.log