Files
org-roamings/20220130131002-jq.org
2022-02-06 20:10:11 +01:00

28 lines
781 B
Org Mode

:PROPERTIES:
:ID: 83908b49-3945-4dce-8b26-2a5e4636df13
:mtime: 20220130131043
:END:
#+title: jq
* Installation
#+BEGIN_SRC shell
apt-get install jq
#+END_SRC
* [[https://github.com/stedolan/jq/wiki/jq-Language-Description][Description du language jq]]
* [[https://github.com/stedolan/jq/wiki/Cookbook][Cookbook]]
* Tips
** Get a object from a list by attribute value
#+BEGIN_SRC shell :results output
raw='[{"name":"dummyNameA","toto":0,"titi":1},{"name":"dummyNameC","toto":2,"titi":3},{"name":"dummyNameB","toto":4,"titi":5}]'
name='dummyNameB'
declare -a infos=($(echo "${raw}" | jq -r '.[] | select(.name | contains("'${name}'")) | (.name) + " " + (.titi|tostring) + " " + (.toto|tostring)'))
echo "infos=${infos[@]}"
#+END_SRC
#+RESULTS:
: infos=dummyNameB 5 4