1AbbenBest Answer · Mar 23, 2020新建个软链接:ln -s /path/to/file /path/to/symlink新建或者更新软链接:ln -sf /path/to/file /path/to/symlink上述路径最好是绝对路径,尤其是当链接就在目录下的时候
1AbbenMar 23, 2020C/C++#include <unistd.h> #include <stdio.h> int main () { if( symlink("/tmp/realfile", "/tmp/link") != 0 ) perror("Can't create the symlink"); }Perl#!/usr/bin/perl if( symlink("/tmp/realfile", "/tmp/link") != 1) { print STDERR "Can't create the symlink: $!\n" }
新建个软链接:
ln -s /path/to/file /path/to/symlink
新建或者更新软链接:
ln -sf /path/to/file /path/to/symlink
上述路径最好是绝对路径,尤其是当链接就在目录下的时候
-s是建立软链接,如果不加就是建立硬链接,可以认为是拷贝了
ln是link的简写
C/C++
#include <unistd.h> #include <stdio.h> int main () { if( symlink("/tmp/realfile", "/tmp/link") != 0 ) perror("Can't create the symlink"); }
Perl
#!/usr/bin/perl if( symlink("/tmp/realfile", "/tmp/link") != 1) { print STDERR "Can't create the symlink: $!\n" }