Home > Operation and Maintenance > Linux Operation and Maintenance > How to delete garbled files under Linux

How to delete garbled files under Linux

巴扎黑
Release: 2017-08-22 14:09:52
Original
2945 people have browsed it

Deleting files under Linux is a very troublesome thing when encountering special characters.

1. If the file name contains characters like '-' or '--'

The deletion method is: rm -- file name

For example, the file name is: -pythontab.tgz

If you use ordinary methods to delete:

rm -pythontab.tgz
Copy after login

The result is error:

rm: invalid option -- pythontab

Try `rm --help' for more information.

can be used:

rm -- -pythontab.tgz
Copy after login

will be deleted successfully.

2. Delete files containing other special characters

For file names containing other special characters, such as <>!*, etc., you can use

"" to escape Symbol or "" double quotation marks to enclose the control

such as ">" or "*"

[root@test]# rm >
[root@test]# rm “*”
Copy after login

3. Delete the garbled file names that the system cannot print (ultimate solution)

There is a file in the system whose file name is all garbled, and there is no way to delete it (the system cannot print garbled symbols). At this time, we can use the inode number to delete it.

[root@test]# ll -i
total 14694452
17956913 -rw-r--r-- 1 test test 4096 Nov 24 16:24 1?.txt
[root@test]# find . -inum 17956913 -exec rm {} \;
Copy after login

After testing, the above method is definitely available

The above is the detailed content of How to delete garbled files under Linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template