我有一个包含以下代码行的 Bash 脚本:
echo "current directory is" $PWD
echo $PWD
# put current directory into a variable for use later in script
originalDirectory=$PWD
echo "contents of original directory variable:" originalDirectory
Run Code Online (Sandbox Code Playgroud)
输出的前 2 行有意义,但第三行没有意义。我希望它输出,contents of original directory variable: /media/sf_code/scripts
但它只是打印变量的名称。为什么它不在该字符串中的冒号后显示 originalDirectory 变量的内容?