How to delete a file with ^? chars in the name?

Jeremy J. Epstein jje at virtech.uucp
Thu Jan 11 01:31:11 AEST 1990


In article <130045 at sun.Eng.Sun.COM>, lm at snafu.Sun.COM (Larry McVoy) writes:
> In article <7711 at unix.SRI.COM> ubi at ginger.sri.com (Ron Ueberschaer x4399) writes:
> >I have a file which is named ^?^?^?H01.b (delete character?) and can't
> >find a way to delete it.  An ls -s on the directory produces:
> >
> >   ..	... (other files)
> >    1	???H01.b
> >
> 
> $ cat > xxx.c
> #include <stdio.h>
> main()
> {
> 	char buf[255];
> 
> 	while (gets(buf))
> 		if (unlink(buf))
> 			perror(buf);
> }
> ^D
> $ cc xxx.c
> $ a.out
> ????H01.b
> ^D

Unfortunately this won't work since the shell is responsible
for expanding the ? and * wildcard characters, not the kernel
(just for fun, consider implementing a shell which used different
wildcard characters...it's only confusing to the user).

Try this:

main()
{
	unlink("\177\177\177H01.b");
}

It also might be worth using "od" to examine the directory...if
the high order bit is on in any of the bytes in the file name, then
the shell won't show them (since most shells strip the high order
bit).  If that's the case, then you would need to use:

main()
{
	unlink("\377\377\377H01.b");
}

-- 
Jeremy Epstein
TRW Systems Division
703-876-4202
jje at virtech.uu.net



More information about the Comp.unix.wizards mailing list