In bash
echo ${!X*}
will print all the names of the variables whose name starts with 'X'. Is it possible to get the same with an arbitrary pattern, e.g. get all the names of the variables whose name contains an 'X' in any position?
Use the builtin command compgen:
compgen -A variable | grep X
2.1m questions
2.1m answers
60 comments
57.0k users