gpt4 book ai didi

linux - cp命令覆盖作为符号链接(symbolic link)的目标文件

转载 作者:IT王子 更新时间:2023-10-29 00:16:45 27 4
gpt4 key购买 nike

cp 命令是否有覆盖作为符号链接(symbolic link)的目标文件的选项?

问题如下:

[dthnguyen@dthnguyen test]$ ls -l
total 8
-rw-rw-r--. 1 dthnguyen dthnguyen 5 Feb 21 09:07 a.txt
lrwxrwxrwx. 1 dthnguyen dthnguyen 7 Feb 21 08:55 b.txt -> ./a.txt
-rw-rw-r--. 1 dthnguyen dthnguyen 5 Feb 21 08:55 c.txt
[dthnguyen@dthnguyen test]$ cp c.txt b.txt

复制完成后,a.txt 有了c.txt 的内容,b.txt 仍然链接到a.txt。预期结果是 a.txt 保留旧内容,b.txt 是一个新的常规文件,与 c.txt 具有相同的内容。

最佳答案

告诉 cp 先删除它。

cp --remove-destination c.txt b.txt

关于linux - cp命令覆盖作为符号链接(symbolic link)的目标文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9371222/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com