반응형
jq 명령어
jq 설치
yum install -y epel-release
yum install -y jq
jq 버전
jq --version
$ jq --version
jq-1.6
jq를 사용하여 json을 한 줄로 변환하는 방법
file.txt 파일
$ cat file.txt
{"ID":"web","Service":"web","Tags":["django"],"Meta":{},"Port":80,"Address":"","Weights":{"Passing":1,"Warning":1},"EnableTagOverride":false,"ContentHash":"318c41a7ce882f20","Datacenter":"vm-dc1"}
cat file.txt | jq .
cat file.txt | jq .
{
"ID": "web",
"Service": "web",
"Tags": [
"django"
],
"Meta": {},
"Port": 80,
"Address": "",
"Weights": {
"Passing": 1,
"Warning": 1
},
"EnableTagOverride": false,
"ContentHash": "318c41a7ce882f20",
"Datacenter": "vm-dc1"
}
--
cat file.txt | jq . > file.json
$ cat file.json
{
"ID": "web",
"Service": "web",
"Tags": [
"django"
],
"Meta": {},
"Port": 80,
"Address": "",
"Weights": {
"Passing": 1,
"Warning": 1
},
"EnableTagOverride": false,
"ContentHash": "318c41a7ce882f20",
"Datacenter": "vm-dc1"
}
cat file.txt | jq -c
cat file.txt | jq -c
{"ID":"web","Service":"web","Tags":["django"],"Meta":{},"Port":80,"Address":"","Weights":{"Passing":1,"Warning":1},"EnableTagOverride":false,"ContentHash":"318c41a7ce882f20","Datacenter":"vm-dc1"}
cat file.txt | jq -c > file.jsonl
$ cat file.jsonl
{"ID":"web","Service":"web","Tags":["django"],"Meta":{},"Port":80,"Address":"","Weights":{"Passing":1,"Warning":1},"EnableTagOverride":false,"ContentHash":"318c41a7ce882f20","Datacenter":"vm-dc1"}
반응형
'리눅스' 카테고리의 다른 글
[리눅스] ping 명령어 (0) | 2020.10.13 |
---|---|
[NGINX] nginx POST 데이터 로깅 (0) | 2020.10.06 |
[Kubernetes] 헬름(helm) 스크립트로 설치 (0) | 2020.10.06 |
[Kubernetes] kubernetes 애플리케이션 배포 -3 (0) | 2020.10.06 |
[리눅스] socat 명령어(proxy) (0) | 2020.10.06 |