jq cheetsheet
jq cheetsheet
October 31, 2021
jq is used to parse JSON result, format and output on the cli.
This document shows brief overview for how to
Basics
- Using variables:
exp as $var | explength as $array_length | add / $array_length
- Boolean operations:
- AND:
exp and exp - OR:
exp or exp
- AND:
- string functions:
contains(substr)returns booleanstartswith(substr)returns booleanjoin(separator)returns string
selectcan be used to filter specific recordsfrom_entriescan be used to parse
Use cases
Get the object of any key
exp | to_entries | .[].value | expOutput CSV/TSV result from JSON
@csv and @tsv can be used to format the array with CSV or TSV
Last updated on