From 7ec64dfbb9d7b1e73363afc8ceb1008ce5a31000 Mon Sep 17 00:00:00 2001 From: syui Date: Sun, 3 Mar 2024 17:23:05 +0000 Subject: [PATCH] =?UTF-8?q?jq=20=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jq.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 jq.md diff --git a/jq.md b/jq.md new file mode 100644 index 0000000..fd39d81 --- /dev/null +++ b/jq.md @@ -0,0 +1,38 @@ +ここでは[aios](https://git.syui.ai/ai/os)にインストールされている[jq](https://github.com/jqlang/jq), [dasel](https://github.com/TomWright/dasel)の`example`をまとめます。 + +## 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 +``` + +```sh +$ echo $json|jq -r ".[]|.name // empty" +aios +archlinux +``` \ No newline at end of file