安裝
git clone https://github.com/stedolan/jq.git cd jq autoreconf -i ./configure --disable-maintainer-mode make sudo make install
參考鏈接
- jq官網
- https://www.cnblogs.com/yy20141204bb/p/4939164.html
- 手冊: https://stedolan.github.io/jq/manual/#example2 打印多個元素 jq .ipclient,.insertDate
日誌處理命令示例
.content 中是一個json字符串,後面對它進行了置換處理
head -n 1 /home/httpLog |./jq .content |sed 's/\\\"/\"/g' |sed 's/.$//' |sed 's/^.//' | ./jq .message
head -n 1 /home/httpLog |/jq .content |sed 's/\\\"/\"/g' |sed 's/.$//' |sed 's/^.//' | jq .message