1833861 Members
2565 Online
110063 Solutions
New Discussion

Re: Cannot Delete a File

 
SOLVED
Go to solution
Peter Maitland
Occasional Advisor

Cannot Delete a File

How do I delete a file that is named -i ? I cannot seem to delete it no matter what I do. Help would be appreciated.

Peter
6 REPLIES 6
Wieslaw Krajewski
Honored Contributor
Solution

Re: Cannot Delete a File

Hi,

For example:
cd /directory
rm ./-i
Permanent training makes master
Rob Smith
Respected Contributor

Re: Cannot Delete a File

Hi, try rm -- -i or ls -il to get the inode number and then change into the directory and find . -inum inode_number -exec rm {} \; to get rid of it. Hope this helps.

Rob
Learn the rules so you can break them properly.
A. Clay Stephenson
Acclaimed Contributor

Re: Cannot Delete a File

cd to desired directory
ls -i to get inode_number
then
find . -inum inode_number -exec rm {} \;
that's it.
If it ain't broke, I can fix that.
Dan Bonham
Advisor

Re: Cannot Delete a File

rm -- -i wil work. Some Administrators will put a file called -i in an important directory to protect it from accidental deletion.
eric stewart
Frequent Advisor

Re: Cannot Delete a File

I would like to compliment the users who answered this question. I had my own round about way of doing it but yours are so much better and easier. I was also impressed with the comment about adding the -i file to a directory where you do not want thing to be removed inadvertantly. I know I have done it.
Thanks again.
Good help is easy to find within forums
Rajeev Tyagi
Valued Contributor

Re: Cannot Delete a File

You can also use rm in interactive mode.
Eg.
rm -i ./*

just say y to the file you want to delete.