如何删除指向同一文件的两个路径中的其中一个?

如何删除指向同一文件的两个路径中的其中一个?

我有这两条路径指向相同的文件,但它们都不是符号链接。如果我使用rm一条路径,另一条路径也会消失(尝试使用另一个具有相同症状的文件),我无法将mv一条路径插入另一条路径。我没主意了

  • .config/pgcli/历史记录
  • 〜/ .config / pgcli /历史记录

一些故障排除

~/dotfiles $ \ls -alL ~/.config/pgcli/history
-rw-rw-r-- 1 lorentz lorentz 3580 jan 25 16:14 /home/lorentz/.config/pgcli/history

~/dotfiles $ \ls -alL .config/pgcli/history
-rw-rw-r-- 1 lorentz lorentz 3580 jan 25 16:14 .config/pgcli/history

~/dotfiles $ \ls -ld ~/dotfiles
drwxrwxr-x 4 lorentz lorentz 4096 jan 22 21:16 /home/lorentz/dotfiles

~/dotfiles $ namei -lx .config/pgcli/history ~/.config/pgcli/history
f: .config/pgcli/history
drwxrwxr-x lorentz lorentz .config
drwxrwxr-x lorentz lorentz pgcli
-rw-rw-r-- lorentz lorentz history
f: /home/lorentz/.config/pgcli/history
Drwxr-xr-x root    root    /
drwxr-xr-x root    root    home
drwxr-x--- lorentz lorentz lorentz
drwx------ lorentz lorentz .config
lrwxrwxrwx lorentz lorentz pgcli -> ../dotfiles/.config/pgcli
drwxr-x--- lorentz lorentz   ..
drwxrwxr-x lorentz lorentz   dotfiles
drwxrwxr-x lorentz lorentz   .config
drwxrwxr-x lorentz lorentz   pgcli
-rw-rw-r-- lorentz lorentz history


~/dotfiles $ \stat ~/.config/pgcli/history
  File: /home/lorentz/.config/pgcli/history
  Size: 3580            Blocks: 8          IO Block: 4096   regular file
Device: 10305h/66309d   Inode: 574283      Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/ lorentz)   Gid: (30001/ lorentz)
Access: 2024-01-25 16:58:09.803772739 +0100
Modify: 2024-01-25 16:14:05.048623557 +0100
Change: 2024-01-25 16:14:05.048623557 +0100
 Birth: 2024-01-25 16:08:51.058707059 +0100

~/dotfiles $ \stat .config/pgcli/history
  File: .config/pgcli/history
  Size: 3580            Blocks: 8          IO Block: 4096   regular file
Device: 10305h/66309d   Inode: 574283      Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/ lorentz)   Gid: (30001/ lorentz)
Access: 2024-01-25 16:58:09.803772739 +0100
Modify: 2024-01-25 16:14:05.048623557 +0100
Change: 2024-01-25 16:14:05.048623557 +0100
 Birth: 2024-01-25 16:08:51.058707059 +0100

~/dotfiles $ mv .config/pgcli/history ~/.config/pgcli/history
mv: '.config/pgcli/history' and '/home/lorentz/.config/pgcli/history' are the same file

我在用

  • Ubuntu 22.04
  • Z壳
  • GNU 存储

答案1

这是一个符号链接的父目录(~/.config/pgcli

(感谢 Raffa 和 muru)

相关内容