1つのディレクトリに同じ名前の複数のファイル/ディレクトリがある可能性がありますか?

1つのディレクトリに同じ名前の複数のファイル/ディレクトリがある可能性がありますか?

同じディレクトリに「storage」という名前の同じ2つのファイル(ディレクトリ)が表示されるのはなぜですか?アイノード番号が異なります。

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#

ベストアンサー1

破損していないファイルシステムでは、同じディレクトリにあるように見えるファイルのinodeとファイル名が異なります。この場合、末尾の空白があるようです。ls -Qファイル名を使用または確認してくださいls -b。 inode 番号を述語とともに使用するか、次の対話型プロンプトでシェル glob を使用してfind指定することで、必要な inode 番号を操作 (名前変更または削除) できます。-inum

for f in storage*; do printf 'removing: —>%b<—\n' "$f"; rm -i -- "$f"; done

おすすめ記事