Skip to content

Instantly share code, notes, and snippets.

@tychobrailleur
Created September 27, 2021 16:58
Show Gist options
  • Save tychobrailleur/1d694d66cffa3338920b63520c65bfa4 to your computer and use it in GitHub Desktop.
Save tychobrailleur/1d694d66cffa3338920b63520c65bfa4 to your computer and use it in GitHub Desktop.
Experiment with env variables in bash
#!/usr/bin/env bash
# Call script with:
# VAL=pouet ./my-script.bash
var_val="${VAL}"
echo ${var_val}
output="$(
echo "[${VAL}]"
)"
echo $output
output="$(
VAL=pouetpouet; echo "[${VAL}]"
)"
echo $output
output="$(
VAL=pouetpouetpouet echo "[${VAL}]"
)"
echo $output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment