Delete Files With Inode Number in Unix or how to delete files with special characters

You can use rm command to delete file.Sometimes, files are created with special characters like control characters and you will not be able to delete them, as you won’t be able to input them via a keyboard.

 

These files are not that easy to delete. Inode numbers comes in handy at this time.

You can find the inode value by using the following command.

geobaby@geo-desktop:~/Desktop$ ls -li
3539141 -rwxrwxrwx 2 geobaby geobaby    4096 2013-05-31 16:36 %$#%  ^%^??#$@#
3153532 -rwxrwxrwx 1 geobaby geobaby 3274861 2013-04-30 17:06 DSCF2091.JPG
3146249 -rwxr-xr-x 1 geobaby geobaby     476 2013-02-22 16:58 gnome-terminal.desktop

Next, use find command to remove the file.

find . -inum [inode-number] -exec rm -fi {} \;

And here it will be:

find . -inum 3539141 -exec rm -fi {} \;

The file will be removed.

Advertisements

One thought on “Delete Files With Inode Number in Unix or how to delete files with special characters

  1. Pingback: Find directory/file with inode number | Linux and Photography Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s