Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 11-24-2004, 09:35 AM   #1
Registered: Jul 2003
Location: Germany
Distribution: Xubuntu, Ubuntu
Posts: 416
Blog Entries: 14

Rep: Reputation: 35
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?

Old 11-24-2004, 09:48 AM   #2
Senior Member
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
You may be able to zap it using a wildcard. e.g. if the file's called "?fish" then use
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
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/
Old 11-24-2004, 10:00 AM   #3
Registered: Sep 2003
Distribution: Woody, SuSE, RH, LAS
Posts: 55

Rep: Reputation: 15
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:
Then just try "rm -rf /backups/my"

Suggestions above also work too.
Old 11-24-2004, 10:08 AM   #4
Senior Member
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

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

Old 11-24-2004, 10:43 AM   #5
Registered: Jul 2003
Location: Germany
Distribution: Xubuntu, Ubuntu
Posts: 416
Blog Entries: 14

Original Poster
Rep: Reputation: 35
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:

/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.

Old 11-24-2004, 11:49 AM   #6
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975
rm -- ?stupid_filename
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.

Last edited by acid_kewpie; 11-24-2004 at 11:51 AM.
Old 11-24-2004, 01:20 PM   #7
Registered: Oct 2004
Distribution: Fedora 7, OpenSuse 10.2
Posts: 108

Rep: Reputation: 15
I think there's an inconsistency in your file system, run fsck.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
filtering a file then deleting it. road69runners Programming 6 12-02-2004 01:54 PM
deleting SMB and starting over? Doug.Gentry Linux - Networking 2 03-17-2004 02:23 PM
deleting a file intellscreen Linux - Newbie 3 11-02-2003 12:39 PM
deleting kcore file? megaspaz Linux - General 1 11-07-2002 04:33 AM
Deleting a file...... lucifer Linux - Software 0 09-03-2002 03:36 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:15 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration