ln -sf
不会覆盖到目录的给定符号链接。
参见例如
% ls -ld program*
drwxr-xr-x 22 b users 4096 Nov 25 14:33 program
drwxr-xr-x 22 b users 4096 Nov 25 14:29 program-201611181546
-rw-r--r-- 1 b users 0 Nov 25 14:34 program-current
% ln -fs program-201611181546 program-current
% ls -ld program*
drwxr-xr-x 22 b users 4096 Nov 25 14:33 program
drwxr-xr-x 22 b users 4096 Nov 25 14:29 program-201611181546
lrwxrwxrwx 1 b users 18 Nov 25 14:34 program-current -> program-201611181546
% ln -fs program program-current
% ls -ld program*
drwxr-xr-x 22 b users 4096 Nov 25 14:33 program
drwxr-xr-x 22 b users 4096 Nov 25 14:34 program-201611181546
lrwxrwxrwx 1 b users 18 Nov 25 14:34 program-current -> program-201611181546
我本来期望的
lrwxrwxrwx 1 b users 18 Nov 25 14:34 program-current -> program
作为解决方法,我可以明确取消链接。
% unlink program-current
% ls -ld program*
drwxr-xr-x 22 b users 4096 Nov 25 14:33 program
drwxr-xr-x 22 b users 4096 Nov 25 14:34 program-201611181546
% ln -fs program program-current
% ls -ld program*
drwxr-xr-x 22 b users 4096 Nov 25 14:33 program
drwxr-xr-x 22 b users 4096 Nov 25 14:34 program-201611181546
lrwxrwxrwx 1 b users 5 Nov 25 14:35 program-current -> program
但我更愿意ln
做这份工作。
这可能吗?如何?