How To Install Jq In Debian, Ubuntu, Alpine, Arch, Kali, Fedora, Raspbian And MacOS?

How To Install Jq In Debian, Ubuntu, Alpine, Arch, Kali, Fedora, Raspbian And MacOS?

jq

A lightweight and flexible command-line JSON processor.

Maintainer: ChangZhuo Chen (u9673u660cu502c)



Section: utils

Install jq

  • Debian apt-get install jq Click to copy
  • Ubuntu apt-get install jq Click to copy
  • Alpine OS apk add jq Click to copy
  • Arch Linux pacman -S jq Click to copy
  • Kali Linux apt-get install jq Click to copy
  • Fedora dnf install jq Click to copy
  • Raspbian apt-get install jq Click to copy
  • macOS brew install jq Click to copy

A lightweight and flexible command-line JSON processor.

How to use jq?

Below are few example commands for jq that you can use in the terminal.

Output a JSON file, in pretty-print format:
jq . file.jsonClick to copy
Output all elements from arrays (or all key-value pairs from objects) in a JSON file:
jq .[] file.jsonClick to copy
Read JSON objects from a file into an array, and output it (inverse of `jq .[]`):
jq --slurp . file.jsonClick to copy
Output the first element in a JSON file:
jq .[0] file.jsonClick to copy
Output the value of a given key of the first element in a JSON text from stdin:
cat file.json | jq .[0].key_nameClick to copy
Output the value of a given key of each element in a JSON text from stdin:
cat file.json | jq 'map(.key_name)'Click to copy
Install the latest version of jq in Debian, Ubuntu, Alpine, Arch, Kali, Fedora, Raspbian and macOS from terminal. To install the jq just copy the above command for your OS and run into terminal. After you run the command it will grab the latest version of jq from the respository and install it in your computer/server.