Search code examples
bashsedrm

How to delete "non-deleteable" files left over from sed -i


So, there are a plethora of questions on this site regarding why using sed -i ... creates a bunch of random files. For me, I ran sed -i ... on a directory and it created a temp file for basically every non-text file in the directory. These files are named xxx.!nnnn!yyy.ext, where the !nnnn part seems to be generated by sed -i.

So, without removing the entire directory and re-cloning the repo, how do I delete them?

$ rm bin/.!27249!CassExporter.jar
$ -bash: !27249: event not found

Solution

  • You can use find:

    find FOLDER -name '*!*' -delete