QuestionQ26

VerifiedInfrastructure and Automation

In a Bash shell, which command appends the current directory to PATH without replacing the existing PATH, for the current shell and any subshells started from it?

Explanation

Appending to PATH so the change persists into subshells requires the bash export builtin combined with a self-referencing assignment such as export PATH=$PATH:$(pwd); plain set statements do not export variables to child shells in bash, and $(...) command substitution (not ${...} variable expansion) is the correct syntax for inserting the current directory's path, whereas prefixing the assignment target with $ is invalid.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!