Free Hosting Online for WorkStations

< Previous | Contents | Next >

Expansions That Return Variable Names

The shell has the ability to return the names of variables. This is used in some rather ex- otic situations.

${!prefix*}

${!prefix@}

This expansion returns the names of existing variables with names beginning with prefix. According to the bash documentation, both forms of the expansion perform identically. Here, we list all the variables in the environment with names that begin with BASH:



[me@linuxbox ~]$ echo ${!BASH*}

BASH BASH_ARGC BASH_ARGV BASH_COMMAND BASH_COMPLETION BASH_COMPLETION_DIR BASH_LINENO BASH_SOURCE BASH_SUBSHELL BASH_VERSINFO BASH_VERSION

[me@linuxbox ~]$ echo ${!BASH*}

BASH BASH_ARGC BASH_ARGV BASH_COMMAND BASH_COMPLETION BASH_COMPLETION_DIR BASH_LINENO BASH_SOURCE BASH_SUBSHELL BASH_VERSINFO BASH_VERSION


Top OS Cloud Computing at OnWorks: