[英]How to make original file not delete when using symbolic link linux
I want to ask when I delete file in folder symlink target, is it possible make the file is still available in original file?我想问当我删除文件夹符号链接目标中的文件时,是否可以使文件在原始文件中仍然可用? I use
ls -n /folder /target
but when I delete file in /target
, in original folder deleted too.我使用
ls -n /folder /target
但是当我删除/target
中的文件时,原始文件夹中的文件也被删除了。
Remove Symbolic Links with rm
使用
rm
删除符号链接
rm symlink_name
Remove Symbolic Links with unlink
使用
unlink
删除符号链接
unlink symlink_name
Unlink
command andrm
command without-R
option doesn't delete regular directory.不带
-R
选项的Unlink
命令和rm
命令不会删除常规目录。 The two commands delete symbolic link from directory because it's considered as a file so, when using the rm or unlink command to remove a symbolic link from a directory, make sure you don't end the target with a / character because that will create an error这两个命令从目录中删除符号链接,因为它被视为一个文件,因此,当使用 rm 或 unlink 命令从目录中删除符号链接时,请确保不要以 / 字符结束目标,因为这将创建一个错误
Please read more in documentation , man pages etc.请在文档、手册页等中阅读更多内容。
As I understood question - you should remove symlink to directory, but make symlink for each file in directory to target directory.正如我理解的问题 - 你应该删除到目录的符号链接,但是为目录中的每个文件创建符号链接到目标目录。 So you will have two normal directories and lot of symlink for files.
因此,您将有两个普通目录和大量文件符号链接。
Only this way you can delete one particular file in target directory and still have it in original directory只有这样,您才能删除目标目录中的一个特定文件,并且仍将其保留在原始目录中
If you want to make it work both ways - to delete file in original directory and still have it in target - make non symlink but hard link with ln for each file.如果您想让它以两种方式工作 - 删除原始目录中的文件并将其保留在目标中 - 为每个文件制作非符号链接但与 ln 硬链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.