Can't delete file with strange name

I have copied some files from a Macbook to a flashcard, and now I want to delete them from the card using my FreeBSD machine. Some files have strange characters in them, and I am unable to delete them. I have searched the forums, but not found a solution. Here is a list of things I have tried:

Code:
sverre % ls
Vivian?3
sverre % ls -l
ls: Vivian?3: Invalid argument
total 0
sverre % rm -- Vivian?3
rm: No match.
sverre % rm *
Do you really want to delete all files? [n/y] y
rm: No match.
sverre % rm ./Viv*
rm: No match.
sverre % rm -- Viv*
rm: No match.
sverre % rm -f -- Viv*
rm: No match.
sverre % find . -name Viv\* -exec rm -- {} \;
find: ./Vivian?3: Invalid argument

I am not able to rename the file either:

Code:
sverre % mv Vivian?3 Viv
mv: No match.

I have no more tricks in my bag. Any ideas?
 
try this:
in terminal with shell, that can complete names, type rm -f Vi and hit tab
That may work
also you may want to try same but using single quotes
 
killasmurf86 said:
try this:
in terminal with shell, that can complete names, type rm -f Vi and hit tab

Thanks for the idea killasmurf! Unfortunately, the filename completion gives the same weird filename, and the result is the same both with and without single quotes.

@dennylin93: I don't use Gnome, so I tried to follow your advice by firing up konqueror as file manager. Unfortunately, it shows no files in the directory where the strange file is.
What is the name of the file manager you used?
 
it might look like same, but shell might interpret it correctly.
It worked for me, when I had some weird characters, that I just couldn't type.
That time I selected text with mouse to copy it later. It worked. [However it is not bulletproof method]
so even if you still see the same, try doing it.

As for your last question to dennyling93, he probably use nautilus (default gnome FM)
you can try x11-fm/rox-filer, it's pretty light-width, or x11-fm/gentoo also very light-width
 
killasmurf86 said:
so even if you still see the same, try doing it.

As for your last question to dennyling93, he probably use nautilus (default gnome FM)
you can try x11-fm/rox-filer, it's pretty light-width, or x11-fm/gentoo also very light-width

Of course I tried it, but unfortunately, it didn't work for me. I will give your suggested Fm's a try, and report back. Thanks!

@ibol: I use tcsh. I tried with single quotes, no luck! Thanks for trying, anyway!

Code:
sverre % rm -- 'Vivian?3'
rm: Vivian?3: Invalid argument
 
what about $ rm -i *
Option -i will ask for confirmation before removing a file

I am not using tcsh but you could try sh
 
Have you tried [cmd=""]rm Vivian\?3[/cmd]?

Failing that, [cmd=""]ls -i[/cmd] should give you an inode to work with and using fsdb(8) (Vorsicht! it is really easy to royally screw up on entire filesystem with fsdb, be super careful!) with "clri" should let you delete it.

Seriously, though: be very careful.
 
sverreh said:
Of course I tried it, but unfortunately, it didn't work for me. I will give your suggested Fm's a try, and report back. Thanks!

@ibol: I use tcsh. I tried with single quotes, no luck! Thanks for trying, anyway!

Code:
sverre % rm -- 'Vivian?3'
rm: Vivian?3: Invalid argument

Usually escaping weird characters with a backslash should work. Outside of single quotes, anyway; but filename completion should have brough it up that way.

Given how resilient this has been, maybe it's some type of locale or language thing, with the ? actually being a special character or the first of a two-byte character.
 
sverre % rm -- Vivian?3

Something like this will never work, the '?' is interpreted by tcsh, meaning "match any character once".
Use either single quotes or an escape character (\?).

Try setting your terminal to UTF-8.
 
You guys are incredibly helpful. I will come back and test your suggestions tomorrow!
Thanks to all for trying to help!
 
So, I have tried some more.

@Killasmurf:

you can try x11-fm/rox-filer

I installed rox-filer, but was unable to make it run. Complained about an error in libglad, I think. I am not able to repeat it now, because for some reason installing it seemed to mess up my Xorg. :r

@Ibol:

what about $ rm -i *

Code:
sverre % rm -i *
rm: No match.

@copypaiste

midnight commander handles these horrors in filenames quite nicely.

I will try that. First I will have to get my system back to normal after I managed to mess it up so badly that Xorg doesn't work. :r

@fronclynne:

Have you tried rm Vivian\?3

Code:
sverre % rm Vivian\?3
rm: Vivian?3: Invalid argument

ls -i
should give you an inode to work with and using fsdb(8)
Code:
sverre % ls -i
ls: Vivian?3: Invalid argument

No luck! Anyway, your warning about fsdb(8) sounded so scary that I doubt I would have the courage to use it! :p

@wblock:

Given how resilient this has been, maybe it's some type of locale or language thing, with the ? actually being a special character or the first of a two-byte character.

You may very well be right. If this is the case, what can I do?

@Carpetsmoker:

Something like this will never work, the '?' is interpreted by tcsh, meaning "match any character once".

You are right. I have just proved it! ;)
Use either single quotes or an escape character (\?).

Unfortunately, that doesn't work either.

Try setting your terminal to UTF-8.

How do I do that?

@adamk:
Perhaps it's even a filesystem error. Have you fsck'ed it lately?

No, I haven't done that. Maybe I will try that later if nothing else helps.
 
Alt said:
You can delete such bad names with command
Code:
find . -name Viv\* -delete

I already tried to use find, in a slightly different way. (See my first post.) I tried your suggestion now, and it gives the same result. find does not like my filename either. This must be a really ugly (but interesting) filename! ;) Here is the result:
Code:
sverre % find . -name Viv\* -delete
find: ./Vivian?3: Invalid argument
sverre %

Thanks for trying!
 
adamk said:
Perhaps it's even a filesystem error. Have you fsck'ed it lately?

I ran fsck on the flashcard. I don't do this kind of thing very often, and am a little bit puzzled: I can't make fsck answer yes, or prompt for an answer to the qustions it asks. It seems that no matter which options I give, it always decides to answer "no".

Code:
# fsck -y -t msdosfs /dev/da0s1
** /dev/da0s1 (NO WRITE)
** Phase 1 - Read and Compare FATs
** Phase 2 - Check Cluster Chains
** Phase 3 - Checking Directories
** Phase 4 - Checking for Lost Files
Next free cluster in FSInfo block (2) not free
Fix? no
60 files, 3905504 free (122047 clusters)
MARK FILE SYSTEM CLEAN? no

***** FILE SYSTEM IS LEFT MARKED AS DIRTY *****
#

I also did the check with fsck_msdosfs, and got the same result. I guess that's because fsck runs fsck_msdosfs when I give
Code:
-t msdosfs

Code:
# fsck_msdosfs -y /dev/da0s1
** /dev/da0s1 (NO WRITE)
** Phase 1 - Read and Compare FATs
** Phase 2 - Check Cluster Chains
** Phase 3 - Checking Directories
** Phase 4 - Checking for Lost Files
Next free cluster in FSInfo block (2) not free
Fix? no
60 files, 3905504 free (122047 clusters)
MARK FILE SYSTEM CLEAN? no

***** FILE SYSTEM IS LEFT MARKED AS DIRTY *****
#

Anyway, does this output indicate an error in the filesystem?
 
Carpetsmoker said:
Try setting your terminal to UTF-8.

Do you mean:
$ xterm -en UTF-8

I tried this, with the same negative result. I also tried

$ xterm -u8

but to no avail.
 
john_doe said:
Did you umount(8) it before running fsck?

No, good point!

Tried without mounting it now:
Code:
#  fsck -y -t msdosfs /dev/da0s1
** /dev/da0s1
** Phase 1 - Read and Compare FATs
** Phase 2 - Check Cluster Chains
** Phase 3 - Checking Directories
** Phase 4 - Checking for Lost Files
Next free cluster in FSInfo block (2) not free
Fix? yes
60 files, 3905504 free (122047 clusters)
MARK FILE SYSTEM CLEAN? yes
MARKING FILE SYSTEM CLEAN
#

Much better! So that means the file system is OK?
But I still can't delete this little bugger! Thanks John!

Do you happen to know what the message "Next free cluster in FSInfo block (2) not free" means? Was it serious, and is fixed now? Or didn't it matter much?
 
sverreh said:
Do you mean:
$ xterm -en UTF-8

I tried this, with the same negative result. I also tried

$ xterm -u8

but to no avail.

~/.Xdefaults
Code:
! Use UTF-8
Xterm*locale: UTF-8

! Set (big) UTF-8 fonts.
*VT100.font:   -misc-fixed-medium-r-normal--20-200-75-75-c-100-iso10646-1

Reload with % xrdb ~/.Xdefaults

Environment:
% setenv LC_CTYPE en_US.UTF-8

I suspect this is a multibyte UTF8 character ...

Regardless, tab completion in TCSH should expand & delete it.
 
sverreh said:
But I still can't delete this little bugger! Thanks John!
Does same error "Invalid argument" still appear when using ls(1) and find(1)? Listing directory contents shouldn't usually fail with any other error than "Permission denied".
 
I've seen that behaviour on some non-UTF8 filenames, because i didn't have the locale set as I was supposed to.
does
[CMD="echo"]*[/CMD]
print the filename?

if it is the only file in the directory, try
[CMD="rm"]-rf DIR[/CMD]
 
Back
Top