Garth Kerr
  • Home

Bash

A collection of 5 posts

Bash

Parsing environment variables with JQ

JQ provides this nifty env input that enables you to reference environment variables using the JQ style query syntax. # prints all envs in JSON format jq -n env And you can use piping

Garth Kerr Garth Kerr
Bash

Bash capture STDOUT to variable without redirecting

Capture CLI to a variable in a bash script without redirecting STDOUT. OUTPUT=$(command --foo "${BAR}" | tee >(cat - >&2))

Garth Kerr Garth Kerr
Bash

Search JSON array with JQ

JQ is a powerful command-line JSON processing tool. It's super fast (C), provides solid documentation, and is easy to use. In this example, given a JSON object from a file, curl response; we

Garth Kerr Garth Kerr
Bash

Iterating over an array of bash variables

I had a requirement for a bash script to check for required variables before running a function. Rather than creating a conditional block for each required variable (or in my case, needing to

Garth Kerr Garth Kerr
Bash

Bash completion for Consul nodes on Ubuntu

After making the jump to Ubuntu as my preferred distribution, I've admittedly become addicted to bash completions (aka autocomplete, tab completion, typeahead). Bash completions provide immediate hints for common commands, and even the

Garth Kerr Garth Kerr
Garth Kerr © 2025
Latest Posts Twitter