yq refresher
Reading YAML in Bash with Examples For YAML files, you'll want to use yq (the YAML equivalent of jq ). Sample YAML File Save this as config.yaml : dev: url: http://dev.com test: url: http://test.com Using yq Extract dev URL $ yq '.dev.url' config.yaml Output: http://dev.com Extract test URL $ yq '.test.url' config.yaml Output: http://test.com Extract both URLs $ yq '.[] | .url' config.yaml Output: http://dev.com http://test.com Store in variables $ DEV_URL=$(yq '.dev.url' config.yaml) $ TEST_URL=$(yq '.test.url' config.yaml) $ echo "Dev: $DEV_URL" $ echo "Test: $TEST_URL" Output: Dev: http://dev.com Test: http://test.com Extract both conditionally (if they exist) $ yq 'keys[] as $env | {env: $env, url: .[$env].url}' config.yaml Output: env: dev url: http://dev.com --- env: test url: http://test.com Load all environments into variables #!/bin/bash # Using yq DEV_URL=$(yq ...