Today encountered a problem, a filename is "-mxv9.log", directly with RM deleted when the error
[Localhost]rm-mxv9.log
Rm:illegal Option--M
Rm:illegal Option--X
USAGE:RM [-rfir] File ...
began to think of the quoted number of deletion, found that the quotation is the same as reported illegal option error
Find some information, found that this file can be deleted
Ls-i the inode of the file, and then use the Find command to delete
[LOCALHOST]LS-ILRT
100985-rw-r--r--1 TBCs users 0 APR 11:32-mxv9.log
100985 of the first column is the inode of the file, and the file can be deleted by executing the following command on the host
[Localhost]find./-inum 100985-exec rm {} \;
This method is suitable for file deletion with garbled file name or special characters.
For example, the file name is "*.txt" if you execute RM *.txt directly, all files in the folder ending in. txt will be deleted.
How to delete files with a file name that is garbled or with special characters under Linux