Can't delete file with strange name

john_doe said:
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".

No change: $ ls lists the file without problems, while $ ls -l fails.

Code:
% ls
Vivian?3
% ls -l
ls: Vivian?3: Invalid argument
total 0
% find . -name Viv\*
find: ./Vivian?3: Invalid argument
%
 
vrachil said:
does
[CMD="echo"]*[/CMD]
print the filename?
Code:
% echo *
echo: No match.
%
vrachil said:
if it is the only file in the directory, try
[CMD="rm"]-rf DIR[/CMD]
Yes, it is the only file left in the directory, so I moved to the parent directory and tried.
Code:
% cd ..
% ls
DCIM            MISC            PRIVATE         Pictures        Skole
% rm -rf Pictures
rm: Pictures: Directory not empty
%

Good idea, but same negative result. Thanks for trying!
 
hmm, any idea how the file came to exist?

you could try removing the file via inode?

eg

Code:
ls -i test
426532045 test

Code:
find . -inum 426532045 -exec rm -i {} \;

this has worked for me previously on linux assume it will work on freebsd also?
 
I'll throw a stick at this.

What if you try quoting the file to be deleleted
$ rm -f "Vivian?3"

Or, if it's the shell misinterpreting the symbol, try a different shell. There are multiple options usually available without installing anything new (sh/csh) and some more options in /usr/ports/shells
 
maybe try using quotes with find?

Code:
find . -name "Viv*" -exec rm -i {}\;
also, the inode idea seems smart enough to work
 
Carpetsmoker said:
~/.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.

I wrote the file .Xdefaults in my home directory. Here is what it looks like:
Code:
% cat .Xdefaults
! 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
%
Then did the reload according to your instructions, and set the environment variable.
Code:
% printenv LC_CTYPE
en_US.UTF-8
%
The file still refuses to disappear! I type:
Code:
% rm -f V
and hit the Tab key. The file name is expanded to
Code:
 rm -f Vivian\?3
and when I press return the following, now familiar, message shows up again:
Code:
rm: Vivian?3: Invalid argument

The same with

$ ls -l

and

$ find

This is getting interesting! ;)
 
Beastie said:
Can you access a machine with Windows installed? You could try to run chkdsk /f on the disk.

Yes, I have access to Windows. What does this command do?

Anyway, I would rather like to find a way of doing this in FreeBSD. This file is not a big problem for me, it occupies less than 1 MB out of the 4 GB on the card. And if I really get desperate I guess I can insert it in the Macbook again and delete it from there. So this is more like solving a puzzle and see what I can learn of new things. Before I ended up with this file I thought I knew everything there was to know about removing strange files from disk. How wrong I was! :O

magickan said:
hmm, any idea how the file came to exist?

you could try removing the file via inode?

eg

ls -i test
426532045 test


find . -inum 426532045 -exec rm -i {} \;

this has worked for me previously on linux assume it will work on freebsd also?

From the name of the file I would guess it contains a picture of my son's girlfriend. (Sorry guys, I can't upload it before somebody finds a way to access it! :e) He had some problems with his Macbook, and I took a backup to a flash card that I normally use in my camera.

Your proposed solution should work, but it doesn't. fronclynne proposed more or less the same in an earlier post, and the result is still negative:

Code:
% ls -i
ls: Vivian?3: Invalid argument
%

OH said:
What if you try quoting the file to be deleleted
$ rm -f "Vivian?3"

Have tried several ways of quoting, so why not this one?
Code:
% rm -f "Vivian?3"
rm: Vivian?3: Invalid argument
%
I have tried Bourne shell to, same miserable result.

vrachil said:
maybe try using quotes with find?

find . -name "Viv*" -exec rm -i {}\;
also, the inode idea seems smart enough to work

Yes, the inode idea is smart, but the command never gets that far:

Code:
% find . -name "Viv*" -exec rm -i {} \;
find: ./Vivian?3: Invalid argument
%

Thank you guys for taking part in this interesting problem!
 
mdhughes said:
Have you tried doing an ls -B to get the special characters that are in the file name?

No, never thought about that. After reading through the manpage for ls I also tried the -b option. But alas:

Code:
% ls -B
Vivian?3
% ls -b
Vivian?3
%

So the file definitely does not want to give up its secrets!
 
sverreh said:
What does this command do?

Anyway, I would rather like to find a way of doing this in FreeBSD.
Like the name suggests, it checks disks. It replaces the old scandisk from Windows 9x (even though chkdsk already existed back then). The /f switch fixes the errors it finds.
I suggested this because when you have a problem with a product designed by Microsoft (i.e. the FAT filesystem), I think it's always better to try to fix it using their tools, especially when you can't seem to be able to fix it otherwise.


sverreh said:
And if I really get desperate I guess I can insert it in the Macbook again and delete it from there.
Which will probably not work any better. After all it caused the problem in the first place. But it's just a guess, don't quote me.
 
Carpetsmoker said:
How about % ls | hd

Another original idea! You guys are bright!
This one gives some output, but I need some help to find out if it helps. I am far outside my comfort zone now. :h

Here we go:
Code:
% ls|hd
00000000  56 69 76 69 61 6e 3f 33  0a                       |Vivian?3.|
00000009
%

As far as I can see from the manpage of hd, this is some kind of hexadecimal representation of the file name. Help to decode this will be appreciated!
 
Beastie said:
Like the name suggests, it checks disks. It replaces the old scandisk from Windows 9x (even though chkdsk already existed back then). The /f switch fixes the errors it finds.
I suggested this because when you have a problem with a product designed by Microsoft (i.e. the FAT filesystem), I think it's always better to try to fix it using their tools, especially when you can't seem to be able to fix it otherwise.



Which will probably not work any better. After all it caused the problem in the first place. But it's just a guess, don't quote me.

Thanks Beastie! I kind of suspected it had something to with checking the disk. ;)
I think the arguments of letting windows fix windows errors is a good one, so I will try it out tomorrow. And I will test it in the Macbook tonight. And I won't quote you. (Not more than the above quote, anyway.)
 
I put the card into the Macbook, and had no problems reading it. It turns out the file is actually a directory with several files in it. Its name is Vivian<3. I was told by the owner that <3 is kind of a smiley for a heart: Just tilt your head 90 degrees to the right, and you will see it! Those stupid young fools. :\

Anyway, I guess our more or less fancy commands to delete the file try to read input from the file called "3", which does not exist. Right?

The bad news is that even though I know the "mysterious" character in the name, I'm still not able to delete it. Tried several variations with backslashes, single and double quotes with rm, rmdir, ls and find without result.

Anyone?
 
Just guessing, but if you know it is a directory,
can you not cd *into* it, move files out of it,
then change back:
Code:
cd ..
/bin/rm -rf "tab" (or something that will work)
 
magickan said:
does


ls -i ../* produce the inode number?

let's see:

Code:
sverre % ls -i ../*
../DCIM:
146432 101_PANA

../MISC:

../PRIVATE:
135168 AVCHD

../Pictures:
ls: Vivian?3: Invalid argument

../Skole:
205824 Hakadal  650240 VGS
sverre %

So, unfortunately, the answer is no.
 
jb_fvwm2 said:
Just guessing, but if you know it is a directory,
can you not cd *into* it, move files out of it,
then change back:
Code:
cd ..
/bin/rm -rf "tab" (or something that will work)

Sorry, did
Code:
cd ..

followed by

Code:
sverre % /bin/rm -rf Pic
and then hit Tab to get

Code:
sverre % /bin/rm -rf Pictures/

and then hit Return to get

Code:
sverre % /bin/rm -rf Pictures/
rm: Pictures/: Directory not empty
sverre %

The problem is I can't move this file, because I always get this "Invalid argument".
And I can't move into the directory for the same reason.
Nice try, though.
 
sverreh said:
Another original idea! You guys are bright!
This one gives some output, but I need some help to find out if it helps. I am far outside my comfort zone now. :h

Here we go:
Code:
% ls|hd
00000000  56 69 76 69 61 6e 3f 33  0a                       |Vivian?3.|
00000009
%

As far as I can see from the manpage of hd, this is some kind of hexadecimal representation of the file name. Help to decode this will be appreciated!

I have way better suggesting
run hd on that directory

I created sample directory X in my /tmp and did # touch Vivian?3
after that
Code:
$ hd /tmp/x
00000000  01 14 01 00 0c 00 04 01  2e 00 00 00 02 00 00 00  |................|
00000010  0c 00 04 02 2e 2e 00 00  02 14 01 00 e8 01 08 08  |................|
00000020  56 69 76 69 61 6e [color="Red"]3f[/color] 33  00 aa 85 a0 00 00 00 00  |Vivian[color="Red"]?[/color]3........|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000200

I think this will be more precise (in case ls interpreted your weird letter as ?)

also did you run that fsck?


BTW this file, that I created I could remove easily $ rm Vivian\?3
 
As killasmurf suggested, an fsck will most likely find and fix the problem. Normally I'd go on to suggest running a utility that doesn't depend on the shell globbing characters and whatnot but "rf -rf dir" would cover that. Do yourself a favor and fsck the drive.
 
killasmurf86 said:
I have way better suggesting
run hd on that directory

I created sample directory X in my /tmp and did # touch Vivian?3
after that
Code:
$ hd /tmp/x
00000000  01 14 01 00 0c 00 04 01  2e 00 00 00 02 00 00 00  |................|
00000010  0c 00 04 02 2e 2e 00 00  02 14 01 00 e8 01 08 08  |................|
00000020  56 69 76 69 61 6e [color="Red"]3f[/color] 33  00 aa 85 a0 00 00 00 00  |Vivian[color="Red"]?[/color]3........|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000200

I think this will be more precise (in case ls interpreted your weird letter as ?)

also did you run that fsck?


BTW this file, that I created I could remove easily $ rm Vivian\?3

Here is my output:

Code:
/% hd Pictures/
00000000  2e 20 20 20 20 20 20 20  20 20 20 30 00 80 01 97  |.          0....|
00000010  b9 3c 21 00 00 00 fd 9e  c1 3c 2f 00 00 00 00 00  |.<!......</.....|
00000020  2e 2e 20 20 20 20 20 20  20 20 20 10 00 80 01 97  |..         .....|
00000030  b9 3c b9 3c 00 00 01 97  b9 3c 00 00 00 00 00 00  |.<.<.....<......|
00000040  e5 2e 00 44 00 53 00 5f  00 53 00 0f 00 cd 74 00  |...D.S._.S....t.|
00000050  6f 00 72 00 65 00 00 00  ff ff 00 00 ff ff ff ff  |o.r.e...........|
00000060  e5 53 5f 53 54 4f 7e 31  20 20 20 22 00 8e f3 9e  |.S_STO~1   "....|
00000070  c1 3c c1 3c 00 00 f3 9e  c1 3c 14 00 04 18 00 00  |.<.<.....<......|
00000080  e5 2e 00 5f 00 2e 00 44  00 53 00 0f 00 a7 5f 00  |..._...D.S...._.|
00000090  53 00 74 00 6f 00 72 00  65 00 00 00 00 00 ff ff  |S.t.o.r.e.......|
000000a0  e5 7e 31 20 20 20 20 20  44 53 5f 22 00 af 01 97  |.~1     DS_"....|
000000b0  b9 3c b9 3c 00 00 01 97  b9 3c 30 00 52 00 00 00  |.<.<.....<0.R...|
000000c0  e5 2e 00 6c 00 6f 00 63  00 61 00 0f 00 f7 6c 00  |...l.o.c.a....l.|
000000d0  69 00 7a 00 65 00 64 00  00 00 00 00 ff ff ff ff  |i.z.e.d.........|
000000e0  e5 4f 43 41 4c 49 7e 31  20 20 20 22 00 b2 01 97  |.OCALI~1   "....|
000000f0  b9 3c ba 3c 00 00 89 75  e7 36 00 00 00 00 00 00  |.<.<...u.6......|
00000100  e5 53 43 30 30 34 38 34  4a 50 47 20 00 b3 01 97  |.SC00484JPG ....|
00000110  b9 3c bb 3c 00 00 f8 8a  3a 3a f1 06 13 0a 04 00  |.<.<....::......|
00000120  e5 53 43 30 30 34 38 36  4a 50 47 20 00 b7 01 97  |.SC00486JPG ....|
00000130  b9 3c bb 3c 00 00 a1 9a  3d 3a fa 06 7f d5 03 00  |.<.<....=:......|
00000140  e5 46 00 61 00 6c 00 6c  00 73 00 0f 00 b0 6b 00  |.F.a.l.l.s....k.|
00000150  6a 00 65 00 72 00 6d 00  00 00 00 00 ff ff ff ff  |j.e.r.m.........|
00000160  e5 41 4c 4c 53 4b 7e 31  20 20 20 10 00 ba 01 97  |.ALLSK~1   .....|
00000170  b9 3c b9 3c 00 00 01 97  b9 3c 02 07 00 00 00 00  |.<.<.....<......|
00000180  e5 79 00 00 00 ff ff ff  ff ff ff 0f 00 63 ff ff  |.y...........c..|
00000190  ff ff ff ff ff ff ff ff  ff ff 00 00 ff ff ff ff  |................|
000001a0  e5 69 00 50 00 68 00 6f  00 74 00 0f 00 63 6f 00  |.i.P.h.o.t...co.|
000001b0  20 00 4c 00 69 00 62 00  72 00 00 00 61 00 72 00  | .L.i.b.r...a.r.|
000001c0  e5 50 48 4f 54 4f 7e 31  20 20 20 10 00 4f 0f 97  |.PHOTO~1   ..O..|
000001d0  b9 3c b9 3c 00 00 0f 97  b9 3c 5b 0f 00 00 00 00  |.<.<.....<[.....|
000001e0  e5 50 00 68 00 6f 00 74  00 6f 00 0f 00 73 20 00  |.P.h.o.t.o...s .|
000001f0  42 00 6f 00 6f 00 74 00  68 00 00 00 00 00 ff ff  |B.o.o.t.h.......|
00000200  e5 48 4f 54 4f 42 7e 31  20 20 20 10 00 99 2f 98  |.HOTOB~1   .../.|
00000210  b9 3c b9 3c 01 00 2f 98  b9 3c b2 6b 00 00 00 00  |.<.<../..<.k....|
00000220  e5 53 00 70 00 61 00 6e  00 69 00 0f 00 3f 61 00  |.S.p.a.n.i...?a.|
00000230  00 00 ff ff ff ff ff ff  ff ff 00 00 ff ff ff ff  |................|
00000240  e5 50 41 4e 49 41 20 20  20 20 20 10 00 a4 2f 98  |.PANIA     .../.|
00000250  b9 3c b9 3c 01 00 2f 98  b9 3c b4 6b 00 00 00 00  |.<.<../..<.k....|
[color="red"]00000260  41 56 00 69 00 76 00 69  00 61 00 0f 00 bc 6e 00  |AV.i.v.i.a....n.|
00000270  23 f0 33 00 00 00 ff ff  ff ff 00 00 ff ff ff ff  |#.3.............|[/color]
00000280  56 49 56 49 41 4e 7e 31  20 20 20 10 00 a1 30 98  |VIVIAN~1   ...0.|
00000290  b9 3c b9 3c 01 00 30 98  b9 3c 79 6e 00 00 00 00  |.<.<..0..<yn....|
000002a0  e5 74 00 65 00 72 00 00  00 ff ff 0f 00 8e ff ff  |.t.e.r..........|
000002b0  ff ff ff ff ff ff ff ff  ff ff 00 00 ff ff ff ff  |................|
000002c0  e5 20 00 56 00 69 00 64  00 65 00 0f 00 8e 6f 00  |. .V.i.d.e....o.|
000002d0  20 00 43 00 6f 00 6e 00  76 00 00 00 65 00 72 00  | .C.o.n.v...e.r.|
000002e0  e5 58 00 69 00 6c 00 69  00 73 00 0f 00 8e 6f 00  |.X.i.l.i.s....o.|
000002f0  66 00 74 00 20 00 69 00  50 00 00 00 6f 00 64 00  |f.t. .i.P...o.d.|
00000300  e5 49 4c 49 53 4f 7e 31  20 20 20 10 00 43 31 98  |.ILISO~1   ..C1.|
00000310  b9 3c b9 3c 01 00 31 98  b9 3c 5d 6f 00 00 00 00  |.<.<..1..<]o....|
00000320  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00008000
/%

Nice idea that gave new information, killasmurf!

From a table of extended ASCII-codes, this is what I find the file name to be:

V NUL i NUL v NUL i NUL a NUL Shift-in NUL 1/4 n NUL ETB small-eth 3

and (possibly) a capital A in the front. I have no idea how I can address this directory. Is it possible to give a file name as octal or hex codes to commands? I mean, is there a way of typing something like

Code:
rm -r \xxx\yyy\zzz

such that rm will see the file?

Yes, i did fsck the card, see post #21
 
There was pretty same problem for me (and konqueror could not show the file too), when i've forgot to set up locales and tried to operate with partially non-ascii named file.

rm -r \xxx\yyy\zzz
It should work. At least as i remember i could open my wrong-encoding-named file with that.
upd: Oh wait, if it IS msdosfs, than no, you can't.
also try viewing man mount_msdosfs for -L and some another encoding option. You need to use both for mounting (e.g. one to decode from msdos-encoding, another to encode to your locale encoding)
Hope that will help.
 
Back
Top