With multiple variables beginning with the same pattern can a wildcard be used to echo all matched patterns?
when zzz1=test1; zzz_A=test2; zzza=test3
What is the best way to match all variables starting with zzz. Where something like echo $zzz*
or for i in $zzz*; do echo $i; done
would output:
test1
test2
test3
bash
you can use${!zzz*}
to expand to all variable names that start withzzz
. There should be something similar inzsh
, though I don't recall what it is. – Yorkshiretypeset -m 'zzz*'
. Details here though: https://mcmap.net/q/1213513/-zsh-equivalent-of-bash-name-or-name – Gratulationecho $zzz
and then a TAB character, Zsh shows all variables starting withzzz
. Ensure thatsetopt auto_list
is set. – Supersedure