Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

230
Visualizações
How do I unset all variables which start with a certain prefix in Bash?

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

MYCONFIG_1=config1
MYCONFIG_2=list2
MYCONFIG_3=random3
MYCONFIG_4=somethingelse4
MYCONFIG_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_1 Would 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.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can do it in a single command, assuming your shell is bash

unset ${!MYCONFIG*}

Note that this will unset all variables beginning with MYCONFIG (no matter if those are environment variables or not).

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda