Showing results for 
Search instead for 
Did you mean: 

ll shows file but not able to delete

Go to solution
Akram Shaik
Frequent Advisor

ll shows file but not able to delete


I am facing problem while deleting file. ll command displays the file but when I try to remove it gives error that file is non existent.

What may be reason?


when everyting is coming your way then you are in the wrong lane
John Kittel
Trusted Contributor

Re: ll shows file but not able to delete

there may be a non-displayable character in the file name. You could try using find, with some known (hopefully unique) part of the filename specified, and wildcard the rest, to find and remove the file. For example, if you know the file has the string "xyz", and few or no other files have that string:

find /dir -name "*xyz*" -ok rm {} \;

This will find files in dir matching the filename and prompt you if you want to remove them or not.

James R. Ferguson
Acclaimed Contributor

Re: ll shows file but not able to delete


No doubt, the file name contains un-printable characters.

You can handle this in various ways. To see the file, you might do:

# ls -bl /path
# rm -i /path/filename* #...and verify the removal

# ls -il /path #...and NOTE the inode number
...then using the inode number from above...
# find /path -xdev -type f -inum -exec rm -i {} \;

Remember! Inode numbers are only unique within a filesystem.


Steve Post
Trusted Contributor

Re: ll shows file but not able to delete

Here's a nice horror story.
A guy was installing an application. The installation script asked where to install. The guy didn't give a an answer so it installed to blank....aka /.

He also put in * for the name of the directory instead of a real name. Oops.

He realized this was a mistake. He wanted to get rid of this directory.

Instead of using the inode number to delete the directory, he ran:

cd /
rm -r *

Instead of removing the * directory, the guy removed everything from the computer. The obvious lesson is: be careful when removing files with weird characters.

Is this an urban legend? Nope. It's true.
It happened in 1995. I know this because I had to fix it. It was a trivial repair on a developer's desktop hpux box.