Bha*_*rat 5 filesystems directory filenames
为什么我在同一目录中看到两个文件(目录)具有相同的名称“存储”?inode 编号不同。
root@OpenWrt:/# fsck.ext4 -p /dev/sda1
/dev/sda1: clean, 2213/979200 files, 2026329/3912206 blocks
root@OpenWrt:/#
root@OpenWrt:/# mount /dev/sda1 /mnt
root@OpenWrt:/# cd /mnt
root@OpenWrt:/mnt# ls -l
drwxr-xr-x 2 root root 4096 Jan 1 1970 etc
drwx------ 2 root root 16384 Jan 31 21:16 lost+found
drwxr-xr-x 9 root root 4096 Apr 14 2018 storage
drwxr-xr-x 3 root root 4096 Jan 20 2018 storage
drwxr-xr-x 11 root root 4096 Apr 3 2018 upper
drwxr-xr-x 3 root root 4096 Jan 1 1970 work
root@OpenWrt:/mnt# ls -li
261121 drwxr-xr-x 2 root root 4096 Jan 1 1970 etc
11 drwx------ 2 root root 16384 Jan 31 21:16 lost+found
391681 drwxr-xr-x 9 root root 4096 Apr 14 2018 storage
783361 drwxr-xr-x 3 root root 4096 Jan 20 2018 storage
130561 drwxr-xr-x 11 root root 4096 Apr 3 2018 upper
522241 drwxr-xr-x 3 root root 4096 Jan 1 1970 work
root@OpenWrt:/mnt#
Run Code Online (Sandbox Code Playgroud)
在未损坏的文件系统上,在视觉上看起来相似的同一目录中的文件将具有不同的 inode 和文件名。在这种情况下,似乎有尾随空格。使用ls -Q或检查文件名ls -b。您可以通过find与-inum谓词一起使用来指定 inode 编号来操作(重命名或删除)您想要的那个,或者使用带有交互式提示的 shell globs;就像是:
for f in storage*; do printf 'removing: —>%b<—\n' "$f"; rm -i -- "$f"; done
Run Code Online (Sandbox Code Playgroud)