How to delete a file or directory with special characters using the inode in Unix or Linux

January 22, 2010
By Andrew Lin

My fat fingers inadvertently created a directory on my unix server with special characters. I could not access this directory nor could I delete it. When I listed the directory using the command ls –b, I could see all the funny characters.

ls –b
scritps010/010/010/010

I tried every command I could think of, rmdir “scripts”, rmdir “scripts010/010/010/010”. The only way to remove this directory was to delete it using the inode number.

To determine the inode use the -i option with the ls command.
ls –i
184538 scritps

Below is the command syntax to delete the directory.
find . –inum 184538 –exec rmdir {} \;

If you wanted to delete a stubborn file then simply substitute rmdir with rm.
find . –inum 184538 –exec rm {} \;

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot
  • del.icio.us
  • IndiaGram
  • IndianPad

Tags: , , ,

Leave a Reply