首先,创建到可执行文件mesher
的软链接,并确认它确实存在:
[me@mine mesh_subdir] ln -s mesher ../mesher
[me@mine mesh_subdir] cd ../
[me@mine project_home] ls
file1 file2 mesher
看起来不错。
现在,我要执行
mesher
:[me@mine project_home] ./mesher
-bash: ./mesher: No such file or directory
为什么?我清楚地在
mesher
中看到文件project_home
。我也尝试按两次Tab键查看所有选项,并且mesher
永远不会显示。同时,cat
和file1
上的file2
正常工作。为什么在我的文件系统中找不到
mesher
,我该怎么办?(这是OS X Sierra上的bash外壳。)
最佳答案
符号链接可以具有相对路径。ln -s mesher ../mesher
行的意思是“在../mesher
中建立到当前目录中名为mesher
的文件的符号链接。现在,当您执行cd ..
时,当前目录将更改-更改链接的目标。
尝试使用ls -l mesher
而不是ls
,您将看到问题:mesher
符号链接指向自身。
相反,可以尝试另一种方法:从符号链接应位于的目录进行链接:
cd ..
ln -s mesh_subdir/mesher mesher
顺便说一句,如果源和目标具有相同的名称,则可以省略链接的名称:在这里
ln -s mesh_subdir/mesher
就足够了。关于linux - 找不到软链接(soft link),即使它很明显,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45857946/