Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5049

How do I unset all variables which start with a certain prefix in Bash?

$
0
0

I have a long list of parameters set in the environmental variables in a VM, e.g.

MYCONFIG_1=config1MYCONFIG_2=list2MYCONFIG_3=random3MYCONFIG_4=somethingelse4MYCONFIG_5=thanksforyourhelp5

I would like to unset all of these in one go, without specifying them each individually (as they will change over time). Is this possible?

I've seen ways to do it individualy, e.g.unset MYCONFIG_1Would successfully remove MYCONFIG_1

Is there a way to reference the prefix MYCONFIG in order to remove all variables that start with that? E.g. something like:

unset MYCONFIG_*

Most thing I have seen are referencing the value, rather than the name.

Many thanks.


Viewing all articles
Browse latest Browse all 5049

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>