117k views
3 votes
What is the correct way to save the current directory to a variable?

A) A=pwd
B) A=pwd
C) pwd | $A
D) $A=cwd

User Muggin
by
8.0k points

1 Answer

2 votes

Final answer:

The correct command for saving the current directory to a variable is A=$(pwd), using command substitution in a Bash shell.

Step-by-step explanation:

The correct way to save the current directory to a variable in a shell such as Bash is to use command substitution. The correct command is A=$(pwd), where pwd stands for "print working directory" and the $() is the command substitution syntax that executes the command inside the parentheses and saves its output to the variable A.

User Saba Jamalian
by
8.1k points