When a program or system malfunctions, it can lead to file names containing special characters or becoming corrupted. Sometimes, using the rm command directly may not work, as shown in the image below:
Here are several methods to delete such files:
1
Use rm — or rm ./ If the file name starts with a ‘-‘, directly deleting it will result in an error. You can use the command:
rm — -test.txt
or
rm ./-test.txt

2
Delete by inode number
1) Use ls -i to find the inode number of the file. For example, if the inode number is 598260:

2) Use the find command to delete it:
find ./ -inum 598260 -exec rm ‘{}’ \;
or
rm `find . -inum 598260`
