jq Command Guide: From Installation to Advanced Usage, A Complete Guide to JSON Data Processing
Recently, while working with scripts to process JSON data on Linux systems, I came across the jq command. On Linux systems, jq is a lightweight command-line tool for handling JSON, commonly used for parsing, querying, and manipulating JSON data.
Installing jq
Linux (Ubuntu/Debian)
1 2
sudo apt update sudo apt install jq
Linux (CentOS/RHEL/Fedora)
Install using the yum or dnf package manager:
1 2 3 4 5
# CentOS/RHEL sudo yum install jq
# Fedora sudo dnf install jq
jq Command Usage
To make things easier, I randomly found a piece of JSON data online and saved it as demo.json. Here’s the original content:
The jq command is often used with pipes. For example, the content of demo.json is compressed and hard to read. By using the jq command, we can format the data to make it more readable.