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

173
Visualizações
How can I manipulate PWD directly?

I knew that there is a variable PWD which is changed when I type the command cd. But when I try to change it manually the current directory isn't changed. How to manipulate PWD directly?

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

0

POSIX describes PWD:

Assignments to this variable may be ignored.

Assignments are not special in bash, dash, ash, zsh or ksh, and the value will simply be overwritten next time the shell changes directory.

over 4 years ago · Santiago Trujillo Relatório

0

While other shells might support such a variable as well, the $PWD variable is generally specific to the bash shell.

The bash manual says:

PWD

The current working directory as set by the cd builtin.

Meaning it will be set when you use the cd builtin to change a directory but bash will not change the current directory when you set $PWD.

over 4 years ago · Santiago Trujillo Relatório

0

At least on my Mac and Linux machines running bash you can just overwrite the variable, so running PWD=/ will change your current directory (in the prompt) to /.

The variable PWD in bash is in control of the shell's working directory (again only the prompt) and you will see that the directory after the PWD= command has been changed but the pwd command isn't impacted by the change.

<0>xxxx@dhcp89-089-034:~$ PWD=/
<0>xxxx@dhcp89-089-034:/$ pwd
/Users/xxxx

Now the environment variable PWD is a bash prompt thing and is not the real working directory, nor is modifying it a useful thing to do unless you actually use the 'cd' command.

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