cp 命令覆盖目标文件(符号链接)
cp 命令是否有任何选项可以覆盖作为符号链接的目标文件?
问题如下:
[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 相同。
Does cp command have any option to overwrite the destination file which is a symbolic link?
The problem is as follows:
[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
After do the copy, a.txt has the content of c.txt, b.txt still links to a.txt. The expected result is a.txt holds the old content, b.txt is a new regular file that has the same content as c.txt.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
告诉
cp
首先将其删除。Tell
cp
to remove it first.