1

So this happened:

$ ls
''$'\342\200''abc2.16.5'
$ ls | od -c
0000000 342 200   a   b   c   2   .   1   6   .   5  \n
$ ls -il
76236897 -rw-rw-r-- 1 mob users 0 Aug 16 17:52 ''$'\342\200''abc2.16.5'

How do I delete this file? Here are some things that didn't work:

$ rm -i -- *
rm: remove regular file ''$'\342\200''abc2.16.5'? y
rm: cannot remove ''$'\342\200''abc2.16.5': No such file or directory

$ rm ./*
rm: cannot remove './'$'\342\200''abc2.16.5': No such file or directory

$ rm ./<TAB>        # for file name completion
rm: cannot remove './'$'\342\200''abc2.16.5': No such file or directory

$ find . -delete
find: cannot delete './\342\200abc2.16.5': No such file or directory

$ perl -e 'unlink(glob("*")) or die $!'
$ perl -e 'unlink(glob("*2.16.5")) or die $!'
No such file or directory at -e line 1.

$ find . -inum 76236897 -delete
find: cannot delete './\342\200abc2.16.5': No such file or directory

$ rename * xxx ; rm -v xxx
rm: cannot remove 'xxx': No such file or directory

Curiously, truncate * --size 0 works, cat * works, shred * works

What should I try next? System is Red Hat Enterprise Linux Server release 6.8

  • Is deleting the directory containing the file an option? – confetti Aug 16 '18 at 21:48
  • Not unless someone knows how to delete a non-empty directory – mob Aug 16 '18 at 21:52
  • rm -rf should do that for you. – confetti Aug 16 '18 at 21:53
  • rm -rf empties a directory first and then deletes it. Sadly, also not working. – mob Aug 16 '18 at 21:54
  • 2
    I think you have file system corruption. Can you boot into read-only mode and run fsck on the partition with the undeletable file? – Deltik Aug 16 '18 at 21:55
1

Since you say shred works, I'd like to suggest adding the -u argument to shred.

From the man page (man shred):

-u deallocate and remove file after overwriting

So I would try shred -n 0 -u * in the directory containing the file.

  • :-( shred: ''$'\342\200''abc2.16.5': failed to remove: No such file or directory . I appreciate the effort though. – mob Aug 16 '18 at 21:53
  • Can you add the output of ls -l to the OP? Curious about how the permissions of the file look. – confetti Aug 16 '18 at 21:56
0

This has happened to me quite often over the years. For me, it has typically occurred on a Windows NTFS partition; you are using RHEL, but maybe the same process will help you.

I have never been able to successfully delete the corrupted file, or the parent directory.

I have always had to:

  • Backup all files (minus the directory with the corrupted file)
  • Format the partition
  • Restore all files

In the event that formatting the partition is not feasible, and the corrupted file isn't causing any real problem, you can also try the following:

  • Put the corrupted file in its own directory
    • copy the corrupted file to a new directory
    • copy all the other good files to a new directory
  • Move the directory with the corrupted file to $TEMP or someplace where it can be safely ignored
  • Put all the other good files back where they were

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.