ファイル名が空のフォルダを削除(?)

ファイル名が空のフォルダを削除(?)

ファイル名が空のフォルダを含むフォルダがあるようです。

$ ls -alF Antonin_Dvorak/
total 12
drwx------ 3 VUW\me VUW\domain users 4096 Jan 22  2015 /
drwx------ 3 VUW\me VUW\domain users 4096 Jan 22  2015 ./
drwx------ 3 VUW\me VUW\domain users 4096 Aug 25 11:10 ../

Pythonでは空のように見えます。

$ python
Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  2 2016, 17:53:06) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.listdir()
['']
>>> len(os.listdir('Antonin_Dvorak')[0])
0

ディレクトリに変更して実行するとlsエラーが発生します。

$ cd Antonin_Dvorak
$ ls
ls: cannot access '': No such file or directory

$ ls -alF
ls: cannot access '': No such file or directory
total 8
d????????? ? ?             ?                   ?            ? /
drwx------ 3 VUW\kaipingga VUW\domain users 4096 Jan 22  2015 ./
drwx------ 3 VUW\kaipingga VUW\domain users 4096 Aug 25 11:10 ../

ある時点で、ファイル名はおそらくキリル文字を含むアルバム/音楽のタイトルであったと仮定していますが、その間にフォルダは別のファイルシステムに移動され、ごみ箱に移動され、ディストリビューションのアップグレードが発生しました。このフォルダを含むファイルシステムは次のとおりです。

$ mount | grep grep $(pwd | head -c 9)
/etc/auto.master.d/issc_nfs_homedir.conf on /vol/home type autofs (rw,relatime,fd=6,pgrp=1310,timeout=300,minproto=5,maxproto=5,direct)
vuwunix01:/vol/vfiler_vuwunix01_data01/users on /vol/home type nfs4 (rw,nosuid,relatime,vers=4.0,rsize=65536,wsize=65536,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=krb5,clientaddr=132.229.239.78,local_lock=none,addr=132.229.18.60)

内容を復元したくなく、Antonin_Dvorakフォルダ全体を削除したいと思います。

$ cd ..; rm -rf Antonin_Dvorak/
rm: cannot remove 'Antonin_Dvorak/': Directory not empty

現在、このコンピュータへのルートアクセス権はありません。このコンピュータはネットワーク共有にあります。私は何をすべきですか?


何を待つ?これを質問本文で編集します。しかし、次のようになります。

$ ls -ial Antonin_Dvorak/
total 12
24005685 drwx------ 3 VUW\kaipingga VUW\domain users 4096 Jan 22  2015 
24005685 drwx------ 3 VUW\kaipingga VUW\domain users 4096 Jan 22  2015 .
47956345 drwx------ 3 VUW\kaipingga VUW\domain users 4096 Aug 25 11:10 ..
$ #So, no surprise here:
$ find . -maxdepth 1 -type d -inum 24005685 -delete
find: cannot delete ‘./Antonin_Dvorak’: Directory not empty

名前のないランダムフォルダではありません。フォルダ自体の名前のないハードリンクですか?

ベストアンサー1

inodeでフォルダを削除できます。

まず、を使用してinode番号を見つけますls -ial Antonin_Dvorak/

出力例:

$ ls -ial Antonin_Dvorak/
total 12
25306387 drwx------ 3 VUW\me VUW\domain users 4096 Jan 22  2015 /
23592962 drwx------ 3 VUW\me VUW\domain users 4096 Jan 22  2015 ./
23592391 drwx------ 3 VUW\me VUW\domain users 4096 Aug 25 11:10 ../

inodeをrmに直接渡すことはできませんが、findにはトリックがあります。

find . -maxdepth 1 -type d -inum 25306387 -delete

例inode(25306387)をシステムのinodeに置き換えてください。

おすすめ記事