Remove a weirdly named file or directory on Linux using inode number


Sometimes threw a weird key combination you might create a weirdly named file on your filesystem which seem hard to remove with rm.
Here is a brief instruction on how to remove those files using its inode number using rm.


[X001] DB01:oracle> ls -ltr
-rw-r--r-- 1 oracle oinstall 0 2009-03-27 15:48 ?(B?[m.
-rw-r--r-- 1 oracle oinstall 0 2009-03-31 22:45 ?(B?[m


[X001] DB01:oracle> rm "?(B?[m"
rm: cannot remove `?(B?[m': No such file or directory

Find the inode numbers of the files to remove :


[X001] DB01:oracle> stat *

File: `33(B33[m'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 802h/2050d Inode: 3211357 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1001/ oracle) Gid: ( 1000/oinstall)
Access: 2009-03-31 22:45:57.000000000 +0200
Modify: 2009-03-31 22:45:57.000000000 +0200
Change: 2009-03-31 22:45:57.000000000 +0200

File: `33(B33[m.'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 802h/2050d Inode: 3211331 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1001/ oracle) Gid: ( 1000/oinstall)
Access: 2009-03-27 15:45:46.000000000 +0100
Modify: 2009-03-27 15:48:47.000000000 +0100
Change: 2009-03-27 15:48:47.000000000 +0100

Find you file by inode number and execute a remove command on it :


[X001] DB01:oracle> find . -inum 3211331 -exec rm -i {} ;
rm: remove regular empty file `./33(B33[m.'? y

[X001] DB01:oracle> find . -inum 3211357 -exec rm -i {} ;
rm: remove regular empty file `./33(B33[m'? y