Deleting Files with Special Character Names
avatar

Have you ever accidently created a file with an unusual name and then tried to remove it, you will find this helpful.  All files in Linux are assigned what is called an inode number.  This unique number allows you to remove a file regardless of it’s name.

To find out the inode number for a file you can type:

stat <filename>

You can also get the inode of every file in a directory using a flag with the ls command:

ls -i
NOTE: The number in front of the file name is the inode number

Now if you want to do a delete by the inode number it is a little but unsual.  You can’t just do an rm you need to do a find and plug the results into the rm command.

find . -inum <inode number> -exec rm -i {} \;

This entry was posted in Linux and tagged , , . Bookmark the permalink.

Leave a Reply