How to find files with "forbidden" characters in their names on a Linux system. Forbidden characters could be non-printable or non-ASCII characters.
Copy and paste these commands in the Linux Terminal.
LC_COLLATE=C find . -name '*[! -~]*'
The "forbidden" characters are returned as they are.
LC_ALL=C find . -name '*[! -~]*'
The "forbidden" characters are returned as questions marks, e.g., "??".
LC_ALL=C find . -name '*[![:print:]]*'
This might not work as well as the two other ones.
Sources:
Another good idea could be to list all filenames with a command like tree
, then save this output to a file, then analyze this file with another command.
When it is done like this, the file system does not have to be scanned so frequently because scanning the whole filesystem takes a lot of time.