删除文件名中带奇数字符的文件

Cam*_*uot 2 linux shell filenames ext2 delete-file

我无法删除作为备份备份副本的文件...我不记得它传递的所有文件系统字符集.

无论如何,今天这里是文件:

nas# ls -al
ls: cannot access Sécurité: No such file or directory
total 32
drwx------ 4 sambacam sambacam 20480 Jun  5 01:38 .
drwxr-xr-x 3 sambacam sambacam 12288 Jun  5 01:38 ..
d????????? ? ?        ?            ?            ? S??curit??
nas# cd S*
cd: 13: can't cd to Sécurité
nas# rm "Sécurité"
rm: cannot remove `S\303\251curit\303\251': No such file or directory
nas# rm S*
rm: cannot remove `S\303\251curit\303\251': No such file or directory
nas# 
Run Code Online (Sandbox Code Playgroud)

我甚至尝试用Python编写代码而没有成功:

nas# python
Python 2.5.2 (r252:60911, Jan 24 2010, 20:48:41) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> d=os.listdir('.')
>>> d
['S\xc3\xa9curit\xc3\xa9']
>>> d[0]
'S\xc3\xa9curit\xc3\xa9'
>>> os.remove(d[0])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 2] No such file or directory: 'S\xc3\xa9curit\xc3\xa9'
>>> 
Run Code Online (Sandbox Code Playgroud)

任何的想法?

我已经运行了fsck来检查是否存在不一致.

sar*_*old 5

我认为你的问题更严重:

d????????? ? ?        ?            ?            ? S??curit??
Run Code Online (Sandbox Code Playgroud)

这意味着ls(1)无法找到文件的权限,链接数,所有者,,大小mtime.它只有一个文件名.

如果目录结构指向文件,但该文件的inode已丢失,则可能发生这种情况.我希望fsck找到它并清理目录条目,但如果没有发生,您可能无法在此文件系统上清空此目录.(你可以将它移动到任何你想要的地方,甚至可以移动到它/lost+found,而不是再被它打扰......)

也许这个debugfs(8)工具对学习更多有用吗?