New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: How to delete a file with a weird name? #3228
Comments
I'm pretty sure termux lacks UTF-8 or UTF-16 support for that matter so you are off better using an actual file manager/explorer. The is also the issue with https://developer.android.com/guide/topics/resources/internationalization and https://developer.android.com/google/play/requirements/target-sdk and how far back termux support goes as is the case with other apps that got booted or stopped getting support on say play store. |
Encoding isn't the case here (on Termux and CLI side) and support of utf8 is present. Command
should work regardless of encoding support as it doesn't operate on file name. @qidizi should try delete file using file manager Android app. P.S. I remember this issue was posted previously somewhere (Reddit?), it was very similar and it was not possible to delete file even using Mixplorer app... |
i think some op like |
Normally the However the mentioned case may happen if issue is actually with file system. Directories I was able to reproduce the issue on my device and this is what I have found:
So basically we dealing with Android bug. I will try to find a way to delete the file and report here. If someone wants to try undeletable file, it can be created this way:
|
Things appear to be quite bad. I can't delete file using PC thorough MTP and ADB.
I will try some other methods but it looks like can be done only by using root. Update: wrote a simple C program to delete all files in current working directory: #include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
int main(void) {
DIR *d = opendir(".");
if (d) {
struct dirent *entry;
struct stat st;
while ((entry = readdir(d))) {
if (stat(entry->d_name, &st) != -1) {
if (S_ISDIR(st.st_mode)) {
printf("Skipping directory: %s\n", entry->d_name);
} else {
printf("Attempting to delete file: %s\n", entry->d_name);
unlink(entry->d_name);
}
} else {
printf("Unable to stat file: %s\n", entry->d_name);
continue;
}
}
}
} It still has no effect on file with weird characters, but there is some interesting detail in strace log:
The I'm closing the issue. Nothing really can be done on unrooted device with such file. I know similar issues was possible quite easily resolve on older Android versions, but on Android 13 things are different. What I can suggest:
|
I can confirm that deleting file with root via However, you can still move the parent directory with Also even though you cannot delete the file itself, you can overwrite it to set its size to |
I was lucky enough to find a solution. Hopefully no one will need to factory reset after this.
This allowed me to delete it; it was possible on Android 14, so probably on other Android versions as well. Is it possible that the package installer has strong permissions and was able to remove it? |
@shiumano Confirming, worked for me by moving directory containing the file to Although if file was created in storage root directory ( |
Problem description
archive same chinese/japanese/english/thai/Russian files into a.zip with mixplorer app;
then unzip a.zip from termux;
rm -rfv *.flac
ls --al *.flac
no flac file deleted.
Steps to reproduce the behavior.
What is the expected behavior?
rm all flac
or
how to delete then
thank you .
System information
The text was updated successfully, but these errors were encountered: