mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-09-10 15:33:50 +02:00
jq: add page (#1092)
This commit is contained in:
parent
b88b9ba3c7
commit
89c2015940
1 changed files with 27 additions and 0 deletions
27
pages/common/jq.md
Normal file
27
pages/common/jq.md
Normal file
|
@ -0,0 +1,27 @@
|
|||
# jq
|
||||
|
||||
> A lightweight and flexible command-line JSON processor.
|
||||
|
||||
- Output JSON file:
|
||||
|
||||
`cat {{file}} | jq`
|
||||
|
||||
- Output all elements from JSON array in file, or all key-value pairs from JSON objects in file:
|
||||
|
||||
`cat {{file}} | jq .[]`
|
||||
|
||||
- Read JSON objects from file, into array, and output (inverse of `jq .[]`):
|
||||
|
||||
`cat {{file}} | jq --slurp`
|
||||
|
||||
- Output first element in JSON file:
|
||||
|
||||
`cat {{file}} | jq .[0]`
|
||||
|
||||
- Output "key" of first element in JSON file:
|
||||
|
||||
`cat {{file}} | jq .[0].{{key}}`
|
||||
|
||||
- Output "key" of each element in JSON file:
|
||||
|
||||
`cat {{file}} | jq 'map(.{{key}})'`
|
Loading…
Add table
Reference in a new issue