Linux, terminal and Git

Stage 3 · Lesson 8 of 8

JSON on the command line with jq

Text tools

JSON is the text format most and many tools use for data. jq is the standard for the terminal. jq . prints JSON neatly indented. .name picks one field.

.items[] goes through each item in a list. select(.active) keeps only the items that match a condition. -r prints plain text without the quote marks.

Together with curl, which fetches a web address, you can question an API from the shell: curl -s URL | jq '.[] | .title'. Scripts use jq the same way to pull values out of and command output. Build filters one step at a time, as with pipelines.

Common trapusing and cut on JSON, which breaks as soon as formatting or field order changes.

A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it

Resources for this stage

Start with· follow one of these

Practise

  • Test regular expressions on sample text with a plain explanation of each part

  • Middle levels need grep, sort, uniq and find to locate the next password

Keep handy

  • The official jq manual with examples for every filter

  • Quick examples for find, sed, awk and friends when you forget the syntax

Mark this stage as not done?