jq cheatsheet

looping over JSON jq -c '.[]' input.json | while read i; do # do stuff with $i done source marshalling JSON strings input {"date":"2018-01-08"} output "{\"date\":\"2018-01-08\"}" command printf "{\"date\":\"2018-01-08\"}" | jq '. | tojson' source unmarshalling JSON strings input Sample test.json contents: "{\"date\":\"2018-01-08\"}" output {"date":"2018-01-08"} command jq '. | fromjson' < test.json source

June 30, 2024 · 1 min

ibmcloud cheatsheet

oauth-token ibmcloud iam oauth-tokens --output json | jq '.iam_token' -r | awk '{printf $2}' | pbcopy

June 30, 2024 · 1 min

git cheatsheet

amend commit with current timestamp git commit --amend --no-edit --date=now source amend commit with current author git commit --amend --no-edit --reset-author source update remote to fetch all branches Check if the remote in question is only configured to pull a single branch. > REMOTE_NAME="origin" > git config --get remote.${REMOTE_NAME}.fetch +refs/heads/master:refs/remotes/origin/master If it is, run the following command to fetch all branches. > REMOTE_NAME="origin" > git config remote.${REMOTE_NAME}.fetch "+refs/heads/*:refs/remotes/${REMOTE_NAME}/*" source

June 29, 2024 · 1 min