cd ~
mkdir bin
export PATH=$PATH:bin
mkdir -p projects
cd projects
echo 'hello world' > hello.sh
chmod +x hello.sh
ln -s hello.sh ~/bin/hello
hello
输出:
-bash: hello: command not found
我是如何改变的:
ln -s hello.sh ~/bin
hello.sh
-bash: /home/qht/bin/hello.sh: Too many levels of symbolic links
我只是想看看发生了什么:
ls -l ~/bin/hello.sh
/home/qht/bin/hello.sh -> hello.sh
我的解决方法是:
ln -sf $PWD/hello.sh ~/bin/hello
ls ~/bin/hello
/home/qht/bin/hello -> /home/qht/projects/hello.sh
而且很有效,我也
为了看看是否有一个方便的选择,我发现:
ln -sfr hello.sh ~/bin/hello
ls -l ~/bin/hello
/home/qht/bin/hello -> ../projects/hello.sh
它起作用了,-r选项起作用了。
如果ln-r可以自动将相对路径数据写入符号链接,为什么没有一个选项maybe-a来执行绝对路径工作呢。
或者,链接的相对路径是否比绝对路径更实用?