Successfully tested on Ubuntu Server 12.04 LTS 64-bit

Ever been stuck with a weird file you wanted to delete? You know, those lock files with special characters in their filenames left all over your Samba shares by some Windows applications (for instance)? Today’s post will help you get rid of them in a snap.

First of all, make sure your current directory is the one where your annoying file is located:

cd directory_containing_weird_file

 
Next, list directory’s content using the –inode option:

ls -i

 
You should now see a listing with a number at the beginning of each line. This number corresponds to the unique inode ID of each file and we’ll use it as identifier for the deletion, instead of our bizarre filename. Just do:

find . -inum inode_ID_of_your_file -exec rm -i {} \;

 
The recalcitrant IS wiped out for good this time!

That’s all Folks!


For further reading, you can take a look at ls and rm man pages which detail some other interesting options.

Advertisements