0

Is it possible to modify an environment variable prior to expanding it?

Example:

set ENV_VAR=some-stuff

echo ${ENV_VAR} - get this to print "somestuff" instead of "some-stuff"
DigitalDisaster
  • 467
  • 3
  • 10
  • 25

1 Answers1

2
$ ENV_VAR=some-stuff
$ echo ${ENV_VAR//[^a-zA-Z]}
somestuff

Parameter expansion (that's the proper terminology for what you call "brace expansion", which is actually something else entirely) accepts modifiers, such as making the first character (or all characters) lower- or upper-case, eliminating a prefix or a suffix, and replacing a pattern with some other string (or with the null string). See "Parameter expansion" in the section "Expansion" in the manual page.

AlexP
  • 4,370
  • 15
  • 15