All tags
jq
Narrow down
Other tips19
- Tip
jq -r '.files[] | @sh' data.jsonjq @sh quotes values so the shell can use them safelyTurns JSON strings into single-quoted shell words that survive spaces and apostrophes.2 Dec 2026 - Tip
jq -n -c '$ARGS.positional' --args a "b c"jq --args puts extra command line words into $ARGS.positionalPasses any number of values from the shell to a jq filter as an array.2 Dec 2026 - Tip
echo '{"id":1,"payload":"{\"user\":\"ann\",\"tags\":[\"x\",\"y\"]}"}' | jq -c '.payload | fromjson | .tags'Jq fromjson opens JSON that was stored inside a stringParses a string field that itself contains JSON, so you can filter into it.2 Dec 2026 - Tip
jq 'with_entries(.key |= ascii_upcase)'jq with_entries renames or drops object keys in one filterRuns a filter on every key and value of a JSON object to rename or drop keys.2 Dec 2026 - Tip
jq empty config.jsonOne empty filter checks that a JSON file parsesCatch a broken config before the program that reads it does.1 Dec 2026 - TipPaths() tells you where in a big JSON document a value livesFind the exact route to a value without scrolling through nested output.1 Dec 2026
- Tip
jq -c --slurpfile u users.json 'Slurpfile joins two JSON files on a shared idAdd names from one export to records in another without writing a program.1 Dec 2026 - Tip
jq '.replicas |= . + 1' deploy.jsonjq |= changes one value and keeps the rest of the documentEdit a field in place, using its current value, without rebuilding the document.30 Nov 2026 - Tip
cut -d: -f1,7 /etc/passwd | jq -R 'split(":") | {user: .[0], shell: .[1]}'Jq -R reads plain text lines, so jq can build records from themTurn ordinary text lines into strings jq can split, filter and wrap.30 Nov 2026 - Tip
jq -r '.[] | "\(.name): \(.description // "no description")"' repos.jsonJq's // operator fills in a default when a field is missingReplace missing or null fields with a fallback value in jq output.30 Nov 2026 - Tip
diff <(jq -S . old.json) <(jq -S . new.json)Jq -S sorts keys, so diff shows what really changed between two filesCompare two JSON files without noise from key order or formatting.30 Nov 2026 - Tip
echo '{"DB_HOST":"db","DB_PORT":5432,"DEBUG":false}' \Jq to_entries turns an object into KEY=value lines for a .env fileConvert a flat object of settings into lines a shell or Docker can read.30 Nov 2026 - Tip
export SITE=example.com RETRIES=3Jq's $ENV reads environment variables straight into a filterPull values from environment variables into jq output without passing them as arguments.30 Nov 2026 - Tip
cat defaults.jsonJq '. * input' merges a config file with an override fileDeep merge two config files so the second one overrides only what it sets.30 Nov 2026 - Tip
ip -j addr show eth0 | jq -r '.[0].addr_info[] | select(.family=="inet") | .local'ip -j prints JSON, so jq can pull out an addressPrints network information as JSON so a script can read an address reliably.28 Nov 2026 - Tip
jq -c '.[]' hosts.jsonjq -c prints each JSON result on a single linePrints every jq result as one compact line, ready for loops and line-based tools.27 Nov 2026 - Tip
jq -s 'length' events.jsonljq -s reads all the JSON input into one array so you can count or sum itCollects every JSON value from the input into one array, so you can count, sum or merge them.27 Nov 2026 - Tip
NAME="web 1"Jq --arg passes a variable from your script into a jq filter without quoting troubleHands shell variables to jq safely, as strings or as real JSON values.26 Nov 2026 - Tip
echo '{"name":"nextdash"}' | jq -r '.name'Jq -r prints strings without the quotesPrints JSON strings as plain text, so jq output works in scripts and loops.19 Nov 2026
Docker4
- Tip
jq -c 'sort_by(-.mem) | .[:2] | map(.name)' containers.jsonjq sort_by with a slice gives you the top 5 of anythingSort records on a field and keep only the first few.30 Nov 2026 - Tip
jq -r '.[] | [.name, .mem] | @tsv' containers.json | sort -t$'\t' -k2 -n | column -tjq @tsv turns API output into columns for cut, sort and awkFlatten records into tab separated lines that classic text tools can handle.30 Nov 2026 - Tip
docker network inspect $(docker network ls -q) \Jq on docker network inspect lists each container's addressSee which subnet a Docker network uses and which address each container got.30 Nov 2026 - Tip
jq -c 'group_by(.state) | map({state: .[0].state, count: length})' containers.jsonjq group_by counts records per value, like GROUP BY in SQLCount how many records share a value, straight from an API response.30 Nov 2026
Media2
- Tip
jq -n -c 'limit(3; range(1; 1000000000))'jq limit(n; stream) stops after n results instead of reading everythingTakes only the first few results of a jq generator and quits early.2 Dec 2026 - Tip
jq -cn --stream 'fromstream(1|truncate_stream(inputs))' big.jsonStream mode reads a huge JSON array without loading it all at onceProcess a file that is too big for a normal jq run.1 Dec 2026
Shell2
- Tip
echo "$TOKEN" | jq -R 'split(".")[1] | gsub("-";"+") | gsub("_";"/") | @base64d | fromjson'Jq @base64d reads the payload of a JWT in the terminalDecode the middle part of a JWT to see its claims and expiry time.30 Nov 2026 - Tip
journalctl -u nginx -n 1 -o json-prettyjournalctl -o json-pretty shows every field of a log entryPrints a full log entry with all its metadata fields, ready for scripting or filtering.24 Nov 2026
Network1
Security1
Nothing matches.