【发布时间】:2012-02-15 11:21:41
【问题描述】:
我刚刚开始学习 Unix,到目前为止遇到了两个基本但难以解决的问题:
- 当我在 shell 脚本中将
HOME=''设置为指定目录时,当前 目录似乎不再被识别。也就是说,'cd ~/' 会吐出消息:'no such file or directory' 消息。尽管奇怪的是,如果在脚本中进行了别名分配,源调用似乎仍然激活了它们。怎么会?
例如:
$ more .profile
HOME="~/Documents/Basics/Unix/Unix_and_Perl_course"
cd $HOME
[...]
$ source .profile
-bash: cd: ~/Documents/Basics/Unix/Unix_and_Perl_course: No such file or directory
- 当我通过 nano ('hello.sh') 创建一个简单的 shell 脚本时,我似乎无法通过在终端中键入 'hello.sh' 来执行它。即使在我 'chmod +x' 文件后,此问题也无法解决。有什么问题?
例如:
$ more hello.sh
# my first Unix shell script
echo "Hello World"
$ hello.sh
bash: hello.sh: command not found
谢谢!
【问题讨论】:
-
这里有两个不同的问题。最好分别问他们。最好给出一个有意义的标题,让问题对未来的读者更有用。
-
感谢您的建议,迈克尔!我会记住的。
标签: macos bash shell unix execution