[英]bash shell $HOME assignment and script execution
我刚刚开始学习Unix,到目前为止,尽管遇到了难以解决的问题,但遇到了两个基本问题:
HOME=''
设置为指定目录时,似乎不再识别当前目录。 也就是说,'cd~ /'吐出消息:'没有这样的文件或目录'消息。 奇怪的是,如果在脚本中进行了别名分配,则源调用似乎仍然激活了它们。 怎么会? 例如:
$ 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
例如:
$ more hello.sh
# my first Unix shell script
echo "Hello World"
$ hello.sh
bash: hello.sh: command not found
谢谢!
您也不想'重载'$ HOME,HOME的默认位置始终是您的主目录。 如果你这样做,很多事情都会破裂。
至于hello.sh-那是因为您没有'。' 在你的$ PATH中。 (这是件好事)
尝试:
./hello.sh
如果它说它无法执行
chmod 755 hello.sh
./hello.sh
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.