A command-line tool to query JSON/XML/YAML/CSV document
For Mac
brew tap thedevsaddam/cli https://github.com/thedevsaddam/homebrew-cli.git
brew install thedevsaddam/homebrew-cli/qFind
cat data.json | q -pretty -find="items.[0].name"Get
cat data.json | q -from="items" -prettycat data.json | q -from="items.[0].name"Command
cat data.json | q -from="prices" -command="first" #first,last,count,avg etcAggregate functions
cat data.json | q -from="prices" -command="avg" #sum,min,max,avg,countcat data.json | q --from="items" -command="min:price"Offset
cat data.json | q -pretty -from="items" -offset="2"Limit
cat data.json | q -pretty -from="items" -limit="4"Distinct
cat data.json | q -from="items" -pretty -distinct="price"Pluck
cat data.json | q -pretty -from="items" -command="pluck:name"Select/Columns
cat data.json | q -from="items" -pretty -columns="name,price"Where
cat data.json | q --from="items" --where="name=Fujitsu"OrWhere
cat data.json | q --from="items" --where="name=Fujitsu" --orWhere="id=int:1"GroupBy
cat data.json | q -pretty -from="items" -groupBy="price"Sort [array]
cat data.json | q -pretty -from="prices" -sort="desc"SortBy [array of objects]
cat data.json | q -pretty -from="items" -sortBy="price:desc"Type [JSON, XML, YAML, CSV]
cat data.csv| q -type="csv" -pretty -where="ISBN=9781846053443" -columns="ASP,ISBN,RRP" # type can be "csv", "xml", "yaml", "json"; default is "json"