【发布时间】:2020-04-23 06:27:57
【问题描述】:
刚刚发现 jq,我想更改键的值并打印更改后的键值和原始键值。
原始样本文件
{
"level": "info",
"ts": 1587565958.8860734,
"logger": "http.log.access.log0",
"msg": "handled request",
"request": {
"method": "GET",
"uri": "/info.php",
"proto": "HTTP/1.1",
"remote_addr": "192.168.0.92:42170"
}
}
过滤器
.ts |= strftime("%Y-%m-%d %H:%M:%S") | .ts, .request[]
输出
"2020-04-22 14:32:38"
"GET"
"/info.php"
"HTTP/1.1"
"192.168.0.92:42170"
需要的输出
1587565958.8860734
"2020-04-22 14:32:38"
"GET"
"/info.php"
"HTTP/1.1"
"192.168.0.92:42170"
jq 玩
【问题讨论】: