![Linux 文件系统 - 删除带有特殊字符的文件夹](https://linux22.com/image/736384/Linux%20%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%20-%20%E5%88%A0%E9%99%A4%E5%B8%A6%E6%9C%89%E7%89%B9%E6%AE%8A%E5%AD%97%E7%AC%A6%E7%9A%84%E6%96%87%E4%BB%B6%E5%A4%B9.png)
我们家里有一台 Linux Debian 服务器作为开发机器。我们的一位开发人员意外创建了一个名为Ð?оваÑ? папка
我怎样才能删除该文件夹?
我尝试了几种方法,例如通配符、通过 inode 编号删除、通过查找删除,但没有任何效果。
我所得到的是
没有这样的文件或目录
以下是我移除测试的完整截图
root@debian:/etc# cd /var/mmstylo
root@debian:/var/mmstylo# ls -la
total 13
drwxrwxrwx 6 www-data www-data 296 Apr 11 18:04 .
drwxr-xr-x 2 www-data www-data 64 Apr 10 13:24 Ð?оваÑ? папка
-rw-r--r-- 1 www-data www-data 4096 Apr 10 13:24 ._.DS_Store
-rw-r--r-- 1 root root 6148 Apr 11 18:04 .DS_Store
drwx------ 2 root root 64 Mar 11 10:31 lost+found
drwxr-xr-x 8 www-data www-data 344 Apr 11 17:21 testwebdav
drwxr-xr-x 8 www-data www-data 280 Apr 10 13:27 webdav
root@debian:/var/mmstylo# rm Ð?оваÑ? папка
rm: cannot remove 'Ð?оваÑ?': No such file or directory
rm: cannot remove 'папка': No such file or directory
root@debian:/var/mmstylo# rm "Ð?оваÑ? папка"
rm: cannot remove 'Ð?оваÑ? папка': No such file or directory
root@debian:/var/mmstylo# mc
root@debian:/var/mmstylo# rm -rf "/var/mmstylo/Ð.оваÑ. папка"
root@debian:/var/mmstylo# ls -li
total 2
93906511492624 drwxrwxrwx 2 root root 64 Apr 10 13:24 Ð?оваÑ? папка
93906511480544 drwx------ 2 root root 64 Mar 11 10:31 lost+found
93906511486864 drwxr-xr-x 8 www-data www-data 344 Apr 11 17:21 testwebdav
93906511487328 drwxr-xr-x 8 www-data www-data 280 Apr 10 13:27 webdav
root@debian:/var/mmstylo# find . -inum 93906511492624 -delete
find: cannot delete ‘./Ð\302\235оваÑ\302\217 папка’: No such file or directory
root@debian:/var/mmstylo# find . -inum 93906511492624 -exec rm -i {} \;
rm: cannot remove './Ð'$'\302\235''оваÑ'$'\302\217'' папка': Is a directory
root@debian:/var/mmstylo# rm *?оÐ*
rm: cannot remove 'Ð'$'\302\235''оваÑ'$'\302\217'' папка': Is a directory
root@debian:/var/mmstylo# find . -inum 93906511492624 -exec rm -ir {} \;
rm: remove directory './Ð'$'\302\235''оваÑ'$'\302\217'' папка'? yes
rm: cannot remove './Ð'$'\302\235''оваÑ'$'\302\217'' папка': No such file or directory
root@debian:/var/mmstylo# mc
root@debian:/var/mmstylo# rm *Ñ. Ð*
rm: cannot remove '*Ñ.': No such file or directory
rm: cannot remove 'Ð'$'\302\235''оваÑ'$'\302\217'' папка': Is a directory
root@debian:/var/mmstylo# rm "*Ñ. Ð*"
rm: cannot remove '*Ñ. Ð*': No such file or directory
root@debian:/var/mmstylo# rm './Ð'$'\302\235''оваÑ'$'\302\217'' папка'
rm: cannot remove './Ð'$'\302\235''оваÑ'$'\302\217'' папка': Is a directory
root@debian:/var/mmstylo# mv /var/mmstylo/'./Ð'$'\302\235''оваÑ'$'\302\217'' папка' /var/mmsytlo/testfolder mv: cannot move '/var/mmstylo/./Ð'$'\302\235''оваÑ'$'\302\217'' папка' to '/var/mmsytlo/testfolder': No suc h file or directory
root@debian:/var/mmstylo# mv './Ð'$'\302\235''оваÑ'$'\302\217'' папка' /var/mmstylo/testfolder
mv: cannot move './Ð'$'\302\235''оваÑ'$'\302\217'' папка' to '/var/mmstylo/testfolder': Input/output error
root@debian:/var/mmstylo# mc
root@debian:/var/mmstylo# ls *Ñ? Ð*
ls: cannot access '*Ñ?': No such file or directory
Ð?оваÑ? папка:
root@debian:/var/mmstylo# rm -r 'Ð?оваÑ?'' папка'
rm: cannot remove 'Ð?оваÑ? папка': No such file or directory
root@debian:/var/mmstylo# rm -r 'Ð?оваÑ?''папка'
rm: cannot remove 'Ð?оваÑ?папка': No such file or directory
root@debian:/var/mmstylo# rm -r 'Ð?оваÑ?' 'папка'
rm: cannot remove 'Ð?оваÑ?': No such file or directory
rm: cannot remove 'папка': No such file or directory
root@debian:/var/mmstylo# rm -r 'Ð?оваÑ?'*'папка'
rm: cannot remove 'Ð?оваÑ?*папка': No such file or directory
root@debian:/var/mmstylo# rm -r 'Ð?оваÑ?*папка'
rm: cannot remove 'Ð?оваÑ?*папка': No such file or directory
root@debian:/var/mmstylo# ls -la
total 13
drwxrwxrwx 6 www-data www-data 296 Apr 11 18:04 .
drwxrwxrwx 2 root root 64 Apr 10 13:24 Ð?оваÑ? папка
-rw-r--r-- 1 www-data www-data 4096 Apr 10 13:24 ._.DS_Store
-rw-r--r-- 1 root root 6148 Apr 11 18:04 .DS_Store
drwx------ 2 root root 64 Mar 11 10:31 lost+found
drwxr-xr-x 8 www-data www-data 344 Apr 11 17:21 testwebdav
drwxr-xr-x 8 www-data www-data 280 Apr 10 13:27 webdav
root@debian:/var/mmstylo# find . -xdev -inum 93906511492624 -exec rm -i '{}' ';'
rm: cannot remove './Ð'$'\302\235''оваÑ'$'\302\217'' папка': Is a directory
root@debian:/var/mmstylo#
我们必须删除此文件夹,因为我们的一些外部客户每次都会收到有关此文件夹的病毒错误和警告。
但它是空的,并且保证没有病毒。
答案1
您已经有几个实例,其中目录名称被正确转义并正确传递给rm
命令,但这些实例导致错误消息,例如:
rm:无法删除
'./Ð'$'\302\235''оваÑ'$'\302\217'' папка'
:是目录
没有任何参数的命令rm
不会删除目录。请尝试rmdir
或使用-r
参数rm