Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!virtech!jje From: jje@virtech.uucp (Jeremy J. Epstein) Newsgroups: comp.unix.wizards Subject: Re: How to delete a file with ^? chars in the name? Summary: shell expands "?" so sample program won't work Message-ID: <1990Jan10.143111.3446@virtech.uucp> Date: 10 Jan 90 14:31:11 GMT References: <7711@unix.SRI.COM> <130045@sun.Eng.Sun.COM> Organization: Virtual Technologies Inc. Lines: 52 In article <130045@sun.Eng.Sun.COM>, lm@snafu.Sun.COM (Larry McVoy) writes: > In article <7711@unix.SRI.COM> ubi@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 > 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@virtech.uu.net