Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 来自外部文件夹的符号链接mac_Macos_Symlink - Fatal编程技术网

Macos 来自外部文件夹的符号链接mac

Macos 来自外部文件夹的符号链接mac,macos,symlink,Macos,Symlink,假设这是我的文件夹结构 filepath\targetpath filepath\folder1 我可以在targetpath文件夹中创建符号链接 ln -s ..\folder1 folder2 但当我试图用下面的命令从上层创建符号链接时 ln -s filepath\folder1 filepath\targetpath\folder2 它创建快捷方式文件,而不是指向文件路径的符号链接 当我在targetpath文件夹之外时,如何创建符号链接?如果符号链接不是绝对路径名(以/开头)

假设这是我的文件夹结构

filepath\targetpath
filepath\folder1
我可以在targetpath文件夹中创建符号链接

ln -s ..\folder1 folder2  
但当我试图用下面的命令从上层创建符号链接时

ln -s filepath\folder1 filepath\targetpath\folder2
它创建快捷方式文件,而不是指向文件路径的符号链接


当我在targetpath文件夹之外时,如何创建符号链接?

如果符号链接不是绝对路径名(以
/
开头),则它是相对于包含链接的目录而不是创建链接时的cwd进行解释的。因此,如果你这样做:

ln -s filepath/folder1 filepath/targetpath/folder2
链接的目标是
filepath/targetpath/filepath/folder1
。您应该以与第一次相同的方式创建符号链接:

ln -s ../folder1 filepath/targetpath/folder2

除非您可以添加某种编程上下文,否则这种类型的问题可能更适合……:)你的斜线向后。路径名
dir/dir/dir/filename
非常有趣,谢谢