From 590059603813059ecf1af5e26e84babdf4e9607d Mon Sep 17 00:00:00 2001 From: syui Date: Sun, 3 Mar 2024 17:14:30 +0000 Subject: [PATCH] =?UTF-8?q?jq=20=E3=82=92=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jq.md | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/jq.md b/jq.md index 96236f8..fd69a5f 100644 --- a/jq.md +++ b/jq.md @@ -1 +1,30 @@ -example \ No newline at end of file +## null + +`id:3`の`name:null`を除外して表示 + +```json +[ + { + "id": 1, + "name": "aios", + "display": "ai os" + }, + { + "id": 2, + "name": "archlinux", + "display": "Arch Linux" + }, + { + "id": 3, + "display": "Linux Kernel" + } +] +``` + +```sh +$ echo $json|jq -r ".[]|{name, display}|select(.name | length > 0)|.name,.display" +aios +ai os +archlinux +Arch Linux +``` \ No newline at end of file