[英]bash shell $HOME assignment and script execution
I've just begun learning Unix and have so far encountered two elementary though difficult to resolve problems: 我刚刚开始学习Unix,到目前为止,尽管遇到了难以解决的问题,但遇到了两个基本问题:
HOME=''
in a shell script to a designated directory, the current directory no longer seems to be recognized. HOME=''
设置为指定目录时,似乎不再识别当前目录。 That is, 'cd ~/' spits out the message: 'no such file or directory' message. Ex: 例如:
$ 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
Ex: 例如:
$ more hello.sh
# my first Unix shell script
echo "Hello World"
$ hello.sh
bash: hello.sh: command not found
Thanks! 谢谢!
You also don't want to 'overload' $HOME, the default location for HOME is always your home directory. 您也不想'重载'$ HOME,HOME的默认位置始终是您的主目录。 If you goof with that, lots of things will break.
如果你这样做,很多事情都会破裂。
As far as hello.sh - thats because you don't have '.' 至于hello.sh-那是因为您没有'。' in your $PATH.
在你的$ PATH中。 (Which is a good thing)
(这是件好事)
Try: 尝试:
./hello.sh
If it says it can't execute 如果它说它无法执行
chmod 755 hello.sh
./hello.sh
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.