Cannot Delete File

 
Amit Dixit_2
Regular Advisor

Cannot Delete File

Hi,
I am having a file which when I do a ll appears in the directory listing, when I try to delete it system gives error message

"No such file or directory"

Permission on the file is rw-r-r and I cannot change permission as well error message "Cant Access".

What could be the issue ?

Thanks,
Amit.
9 REPLIES 9
Warren_9
Honored Contributor

Re: Cannot Delete File

hi,

i think you filename may contains some control character, try to use "rm -i *filename*" to remove the file.
Rita C Workman
Honored Contributor

Re: Cannot Delete File

Get the inode with ll -i and then do as Warren suggest. Or maybe would rm "file name in quotes" work for ya.

Rgrds,
Rita
morganelan
Trusted Contributor

Re: Cannot Delete File

May be there are some control characters attached to the file name.

# echo * | cat -v

Look for any control characters displayed

# rm -rf *application*

Kamal Mirdad
Devender Khatana
Honored Contributor

Re: Cannot Delete File

Hi,

ll with -b option can also be used to display files with special characters. Once you find there are special characters in the file remove it using rm with -i option as you use wild characters in the arguments.

#ll -b

#rm -i *filename or filename*

(Put * depending upon the location of control character in the file)

HTH,
Devender
Impossible itself mentions "I m possible"
vinod_25
Valued Contributor

Re: Cannot Delete File

hi Amit

As others say this is due to a special character incorporated in your file...

One more trick that I use is

rm (filename)

Where is the escape key
Hit the escape key twice and that will auto complete the command and will automatically find the name with hidden/non ascii characters and complete the word.

cheers!!!

Vinod
Matthew_50
Valued Contributor

Re: Cannot Delete File

Get the directory i-node number
1. #ll -i directoryname|awk '{print $1}'

Verify i-node number via find
2. #find $PWD -inum XXXXXXX -exec ll {} \;

If output match the directory name, then
3. #find $PWD -inum XXXXXXX -exec rm -rf {} \;

Mark Grant
Honored Contributor

Re: Cannot Delete File

If you're really bored and need yet another approach

ls > somefile

edit "somefile" to remove everything except the file you want to remove and insert an "rm " in front of the file name. Then save it.

sh somefile

I like to do it that way sometimes just to see how odd the filename really is.
Never preceed any demonstration with anything more predictive than "watch this"
Mark Grant
Honored Contributor

Re: Cannot Delete File

Oops, didn't see how old this one was.
Never preceed any demonstration with anything more predictive than "watch this"
Cem Tugrul
Esteemed Contributor

Re: Cannot Delete File

Amit,

it depends on some control charecters
i have also many end-users and many times
they use turkish characters while creating
files although i warn them so when i want to
reduce FS about their home dir i face same
problems...the solution i prefer;

rm -i filename

And also i sometimes apply as Mark's solution

Good Luck,
Our greatest duty in this life is to help others. And please, if you can't