back to labs
jq: Query a JSON Inventory
EasyCommand Line Essentials10-20 minThe brief
Query a JSON inventory with jq. The data is /root/case/inventory.json, an array of host objects like {"host":"node00","role":"web","cpus":4,"active":true}. Produce three answers:
/root/case/total.txt— total number of hosts/root/case/active.txt— number of hosts withactive == true/root/case/roles.txt— the distinct roles, sorted, one per line
The data varies per session. See /root/case/brief.txt.
What you'll do
- Count records with jq 'length'
- Filter with select() and count the subset
- Extract a field across an array and dedupe with unique
- Print raw string output with -r
Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.
