Shell script
Jump to navigation
Jump to search
POSIX shell
https://pubs.opengroup.org/onlinepubs/9699919799/idx/shell.html
Bash shell
Security
- about variable quotes https://unix.stackexchange.com/questions/171346/security-implications-of-forgetting-to-quote-a-variable-in-bash-posix-shells
Parameter substitution
- from https://tldp.org/LDP/abs/html/parameter-substitution.html
- and https://www.cyberciti.biz/tips/bash-shell-parameter-substitution-2.html
#!/usr/bin/env bash set -o errexit -o nounset -o pipefail BAR_A_ROOT=1 BAR_A_PATHS=2 BAR_B_ROOT=3 BAR_C_PATHS=4 BAR_D_ROOT=5 BAR_D_PATHS=6 for VAR in ${!BAR_*} do VALUE=${!VAR} V=${VAR#BAR_} ONE=${V%%_*} TWO=${V##*_} echo \'$ONE\' \'$TWO\' \'$VALUE\' done