我正在阅读 Wrox,开始 Linux 编程。但我有一个关于 shell 变量的问题。
这是一个名为 test.sh 的 shell 脚本:
#! /bin/bash
read test
echo $test
exit 0
然后我 chmod 脚本:
$ chmod +x test.sh
$ ./test,sh
当我输入“ok”时,它会回显“ok”。
但是当我回到 shell 界面时,我输入了:
$ echo $test
它什么也没返回...
我不知道为什么 $test 不像脚本那样返回“ok”......而且这本书没有提到它......
提前致谢:)