014 linux 命令行工具jq

安裝

git clone https://github.com/stedolan/jq.git
cd jq
autoreconf -i
./configure --disable-maintainer-mode
make
sudo make install

參考鏈接

  1. jq官網
  2. https://www.cnblogs.com/yy20141204bb/p/4939164.html
  3. 手冊: 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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章