4

I am not being able to delete certain files with an error no such file or directory. A file on my desktop as well as a file in my movies folder is not being deleted.

I am 100% sure the problem isn't with the name of the file because I always use tab key to auto complete the name.

Error

enter image description here enter image description here

4 Answers4

1

the name of the file must contain a non-printing character i.e. a character that is not printed even if is there.

you should try this:

ls -b <your file> | xargs rm

you should get the full name of that file by typing the first few letters then pressing tab

Alex Jones
  • 7,982
  • 9
  • 55
  • 94
1

I had the same problem as yours, only with a folder, not with a file. None of the methods suggested here worked.

I managed to solve the problem by creating a folder in the same position and with the same name as the one I couldn't delete. The folder was created correctly and it "replaced" the non existing one. Then I simply removed the new folder and the issue was gone. Simply as that.

Marco
  • 991
  • 9
  • 13
0

Open a terminal and type:

rm or sudo rm remember this is for a file not a directory, if it's directory then rm -r, more detailed man rm.

Now when you typed rm command just drag&drop that file to a terminal, it will also print/show you a complete and correct path to that file, out of it you can notice if you made any mistakes when providing a path to a file before. And then just hit Enter that's it.

If you still unable to delete it, follow this duplicated link.

JoKeR
  • 6,972
  • 9
  • 43
  • 65
0

As you didn't do a 'ls -l ~/Desktop' it is hard to know what exactly is the problem. Would be nice if you could update your post with that.

The absolute simplest solution is to let the terminal find out the exact name itself by autocompletion. Genereally you just start to write the command and then hit the tab key.

rm F[Tab-key]

It should then write out the whole name of the file. You might possibly have to press Tab twice for it to do that.

AlMehdi
  • 552