LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Deleting a file starting with a ? (https://www.linuxquestions.org/questions/linux-general-1/deleting-a-file-starting-with-a-258788/)

bitpicker 11-24-2004 09:35 AM

Deleting a file starting with a ?
 
I have a strange phenomenon on my harddisk: I copied a lot of files in various subdirectories into a directory /backup before updating the system, and after that went well the files were no longer needed and I wanted to delete them. But there is one file which I cannot delete because for reasons I don't know it has turned out to have a question mark as the first symbol. The command line doesn't even show the file using ls with any parameters, but I can see it in mc. As it is in a subdirectory, I can't delete the directory and the ones above either.

Any suggestions?

Robin

rjlee 11-24-2004 09:48 AM

You may be able to zap it using a wildcard. e.g. if the file's called "?fish" then use
Code:

rm *fish
It's likely that mc is using the ? character to replace a non-printing character (maybe something like an invalid wide character), so you won't be able to do this by typing in the filename.

Another option is
Code:

rm /backup/* /backup/.*
but be aware that you may need to fsck your disk after doing this, as it could remove the . and .. directory links from /backup/

andguent 11-24-2004 10:00 AM

Am I reading you correctly that it is a subdirectory within a parent directory that should also be deleted?

If you run "rm -rf /backups/mybackupfolder" it will delete mybackupfolder and everything it contains.

If you want to delete
"/backups/my" which contains:
"/backups/my/backup/folder/?confusedfolder"
Then just try "rm -rf /backups/my"

Suggestions above also work too.

theYinYeti 11-24-2004 10:08 AM

Or
rm '?fish'
Or
rm \?fish
Or
rm -i *
and answer "yes" only to the one you really want to delete.

Yves.

bitpicker 11-24-2004 10:43 AM

None of these suggestions work. Some more detail: on a command line as root, if I enter the directory the file is in, 'ls' without any parameters produces the following output:

Code:

/bin/ls: powErpmc250.h: File or directory not found (actually that is in German)
.  ..

So it does see the file, as it gives me its correct name, but cannot handle it, paradoxically giving me its name while stating it can't find the file.

In mc the filename is the same but with a ? in front, and it is red - the colour mc on my system uses to mark erroneous things such as symlinks missing their target. Mc lists the file as zero length and with a date of Jan 1st 1970.

I can even touch powErpmc250.h in the same directory, after which I have two files of the same name in there, with no question mark. The question mark reappears when I delete one, I can't delete both at once, nor the directory they're in. If I copy another file into the directory and change its name to the same as the offending file, both are listed with identical properties, but only one can be deleted, one always remains and reverts to zero length etc.

Robin

acid_kewpie 11-24-2004 11:49 AM

normally
Code:

rm -- ?stupid_filename
or
rm \?stupid_filename

would do it... but sounds like you might have slightly deeper problems there... can you stat the file correctly? always try to use tab completeion inder bash too, to ensure that it can see the file at that leve, and there's no chance of a typo.

LasseW 11-24-2004 01:20 PM

I think there's an inconsistency in your file system, run fsck.


All times are GMT -5. The time now is 07:04 PM.