0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

jq コマンド | 「配列内のハッシュ」を値で絞り込む or 除外する

Last updated at Posted at 2018-06-20

JSONファイルの例

配列の中にハッシュが連なっている例。

[
  {
    "name": "Alice"
  },
  {
    "name": "Bob"
  },
  {
    "name": "Carol"
  }
]

valueで絞り込む場合

cat name.json | jq '.[] | select(.name == "Bob")'

{
  "name": "Bob"
}

valueで除外する場合

$ cat name.json | jq '.[] | select(.name != "Bob")'

{
  "name": "Alice"
}
{
  "name": "Carol"
}

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?