ubi@ginger.sri.com (Ron Ueberschaer x4399) (01/09/90)
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 If I do an ls *.b, it lists the other .b files, but complains: H01.b not found I've tried: rm -i * (to selectively delete everything) rm "???H01.b" rm "^v^?^v^?^v^?H01.b" (control-v delete ...) and nothing seems to work. Help me, o wizards! --Ron Ueberschaer ubi@unix.sri.com ...!{hplabs,rutgers}!sri-unix!ubi
lm@snafu.Sun.COM (Larry McVoy) (01/10/90)
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 > >If I do an ls *.b, it lists the other .b files, but complains: > > H01.b not found > >I've tried: > > rm -i * (to selectively delete everything) > rm "???H01.b" > rm "^v^?^v^?^v^?H01.b" (control-v delete ...) > >and nothing seems to work. $ 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 --- What I say is my opinion. I am not paid to speak for Sun, I'm paid to hack. Larry McVoy, Sun Microsystems (415) 336-7627 ...!sun!lm or lm@sun.com
roy@comcon.UUCP (Roy M. Silvernail) (01/10/90)
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. Here's one way to do it: /bin/ls>foo edit foo with vi to delete all other lines and insert rm in front of the filename in question. Save it and 'sh foo' -- _R_o_y _M_. _S_i_l_v_e_r_n_a_i_l | UUCP: uunet!comcon!roy | "Every race must arrive at this #include <opinions.h>;#define opinions MINE | point in its history" SnailMail: P.O. Box 210856, Anchorage, | ........Mr. Slippery Alaska, 99521-0856, U.S.A., Earth, etc. | <Ono-Sendai: the right choice!>
jje@virtech.uucp (Jeremy J. Epstein) (01/10/90)
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 <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@virtech.uu.net
richd@hplvli.HP.COM (Rich Dykstra) (01/10/90)
I have found: rm -i * invaluable for removing files containing special characters. To remove file names beginning with a dash (how can this happen?) like "-somename" use: rm -i junk *
peter@ficc.uu.net (Peter da Silva) (01/11/90)
Browse is an excellent tool for this sort of thing. You can either ddelete the file or Rename it to something palatable. -- _--_|\ Peter da Silva. +1 713 274 5180. <peter@ficc.uu.net>. / \ \_.--._/ Xenix Support -- it's not just a job, it's an adventure! v "Have you hugged your wolf today?" `-_-'
lm@snafu.Sun.COM (Larry McVoy) (01/11/90)
In article <1990Jan10.143111.3446@virtech.uucp> jje@virtech.uucp (Jeremy J. Epstein) writes: >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 <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). You're out of your mind. The shell does not come inbetween a the keyboard and gets(). --- What I say is my opinion. I am not paid to speak for Sun, I'm paid to hack. Larry McVoy, Sun Microsystems (415) 336-7627 ...!sun!lm or lm@sun.com
andyc@hpopd.HP.COM (Andrew Cunningham) (01/11/90)
Jeremy J. Epstein (jje@virtech.uucp) wrote: >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: >> > rm -i * Then hit `n' for every file but the right one. If you're too paranoid to try this then use ls -il find . -inum <num> -exec rm -i {} \; where <num> is the inode numbert listed with ls -i. No C programs, no hacks, just one or two simple commands. Why does this discussion go on forever everytime the question is asked?
chris@choreo.COM.COM (Chris Hare / System Manager) (01/11/90)
Organization : Choreo Systems Inc, Ottawa, Canada 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 > > If I do an ls *.b, it lists the other .b files, but complains: > > H01.b not found > > I've tried: > > rm -i * (to selectively delete everything) > rm "???H01.b" > rm "^v^?^v^?^v^?H01.b" (control-v delete ...) > > and nothing seems to work. > > Help me, o wizards! > This solution was published in UNIX World magazine a couple of years ago The source code is found after the "---cut here---" line. The little C program requires that your pwd be the directory where the file to remove is. You must find out the i-node number of the affected file ( using ls -i ). After you have it, you run this program with the i-node number as the argument, and the filename will be changed from 'junk' to fix.out. Then you can delete it, or do want you want with it. We have this implemented on a SCO XENIX 386, SCO UNIX 386, Motorola UNIX V/68, AT&T UNIX SysV.2, SysV.3. ------------------------------------------------------------------------ Chris Hare, Coordinator, Systems Management Choreo Systems Inc email : uunet!choreo!chris Tel 613-238-1050 Fax 613-238-4453 ---cut here--- #include <stdio.h> #include <sys/types.h> #include <sys/dir.h> #include <ctype.h> #define FIXOUT "fix.out" /* output file name*/ main(argc,argv) int argc; char *argv[]; { struct direct dbuf; int fd,fix_ino; if ( argc != 2 || !isdigit( argv[1][0])) { fprintf(stderr, "\nUsage: %s inode-number\n", argv[0]); exit(1); } fix_ino = atoi(argv[1]); if ((fd = open(".", 0)) < 0) { fprintf(stderr, "\nCan't read current directory.\n"); exit(2); } while (read(fd, (char *) &dbuf, sizeof(dbuf)) > 0 ) { if ( dbuf.d_ino != fix_ino) continue; unlink(FIXOUT); /* erase former fix */ link (dbuf.d_name, FIXOUT ); /* new link */ unlink(dbuf.d_name); /* erase old link */ printf("\nFixed it: inod-number = %d\n", fix_ino); printf("old name was :%s:\n",dbuf.d_name); printf("new name is :%s:\n",FIXOUT); exit(0); } close(fd); printf("\nCouldn't find it !!!\n"); }
ted@hpwrce.HP.COM ( Ted Johnson) (01/12/90)
>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 1)do an "ls -i" to get the inode number of the file. 2)from the directory that the offensive file is in, do: find . -inum N -exec rm {} \; where N is the inode number of that file. -Ted
jik@athena.mit.edu (Jonathan I. Kamens) (01/12/90)
In article <130103@sun.Eng.Sun.COM>, lm@snafu.Sun.COM (Larry McVoy) writes: >In article <1990Jan10.143111.3446@virtech.uucp> jje@virtech.uucp (Jeremy J. >Epstein) writes: >>In article <130045@sun.Eng.Sun.COM>, lm@snafu.Sun.COM (Larry McVoy) writes: >>> $ 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). > >You're out of your mind. The shell does not come inbetween a the keyboard >and gets(). OK, let's take this very simply and stop insulting each other. This is comp.unix.wizards, not alt.flame (Frankly, since this IS comp.unix.wizards, it is completely unbelievable to me that we are ONCE AGAIN having this stupid discussion. It is explained in the Frequently Asked Questions posting of comp.unix.questions, and even with that it comes up every couple of months, or even more frequently than that.). The original poster complained that his file contained three delete characters. Now, from his description of the problem, I would have to question his conclusion that the characters in question are delete characters; if ls displays them as ? or ^?, they could be any garbage control character. Your solution, Mr. McVoy, therefore has two flaws. First of all, it appears to assume that the user can type whatever characters are in the flawed filename (and that he also knows the correct characters to type), and that gets will not choke on them. Neither of these assumptions is necessarily correct. Second, when you illustrate the use of the program, you show the user typing three question marks ("???") in place of the three unknown control characters. Now, it's quite possible that yuou meant those question marks to be delete characters (which, as I pointed out above, isn't necessarily going to work either, since they quite possibly aren't delete characters in the filename), but THAT'S NOT WHAT YOU TYPED. What you typed are question marks, and (as Mr. Epstein pointed out) the only way question marks could possibly do any good is if you were expecting them to be expanded somehow into the garbage control characters. Now, as several people have already pointed out, there is no need to write special purpose programs to delete a file with a junk name, or to rename it. Several standard Unix utilities will very easily allow a user to rename a file with a garbage name, except in extremeley rare circumstances. My personal preference is ls -li to get the inode number and the find -inum to deal with it. Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8495 Home: 617-782-0710
szirin@cbnewsm.ATT.COM (seth.zirin) (01/12/90)
If this isn't one of the "Frequently Asked Questions" it should be added to the list. Much more of this and I'll persuade a new user to ask "How do you tell a wizard?" or even better yet, "What do you call a female wizard?" The period between these episodes seems to be growing shorter and shorter. Followup-To: junk
jonathan@cs.keele.ac.uk (Jonathan Knight) (01/12/90)
From article <8000004@hpopd.HP.COM>, by andyc@hpopd.HP.COM (Andrew Cunningham): > Jeremy J. Epstein (jje@virtech.uucp) wrote: >>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: [various weird ideas deleted] > No C programs, no hacks, just one or two simple commands. Why does this > discussion go on forever everytime the question is asked? Why doesn't anyone suggest 'rm ???H01.b' - assuming that there are no other file names ending in H01.b which are exactly 8 chars long this will work fine. -- ______ JANET :jonathan@uk.ac.keele.cs Jonathan Knight, / BITNET:jonathan%cs.kl.ac.uk@ukacrl Department of Computer Science / _ __ other :jonathan@cs.keele.ac.uk University of Keele, Keele, (_/ (_) / / UUCP :...!ukc!kl-cs!jonathan Staffordshire. ST5 5BG. U.K.
guy@auspex.auspex.com (Guy Harris) (01/13/90)
>No C programs, no hacks, just one or two simple commands. Why does this >discussion go on forever everytime the question is asked? Perhaps because: 1) people don't read the "frequently asked questions" list, which discusses, among other questions, "how do I remove files with funny characters in their names"; 2) the question is sometimes asked in a fashion that indicates some confusion; for example, the symptoms the person gave seem to indicate that the three characters at the front of the file name are neither <DEL> (a/k/a ^? or "control-question-mark) nor ? (question mark), but some unknown characters with the 8th bit set (which some versions of "ls" will print as "?" under the assumption that they're not printable). The latter seems to be the source of at least some of the debate here....
gwyn@smoke.BRL.MIL (Doug Gwyn) (01/13/90)
In article <8502@cbnewsm.ATT.COM> szirin@cbnewsm.ATT.COM (seth.zirin,lc,) writes: > "How do you tell a wizard?" You can tell a wizard but you can't tell him much. > "What do you call a female wizard?" Ma'am.
sms@WLV.IMSD.CONTEL.COM (Steven M. Schultz) (01/13/90)
In article <2817@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) writes: >>No C programs, no hacks, just one or two simple commands. Why does this >>discussion go on forever everytime the question is asked? > >Perhaps because: > > 1) people don't read the "frequently asked questions" list, > which discusses, among other questions, "how do I remove > files with funny characters in their names"; But this is supposed to be the "wizards" group - this particular question (one would have hoped till recently at any rate that this "problem" is one an 'apprentice' would be able to handle) shouldn't have even come up here, must less be the cause of hitting 'n' till the poor key wore out. Steven M. Schultz sms@wlv.imsd.contel.com
jik@athena.mit.edu (Jonathan I. Kamens) (01/15/90)
You know, I seem to recall that the thing which got the ball rolling enough to get a Frequently Asked Questions posting started was a flame by me about a discussion very similar to this one ("How do I get a listing of all the files and directories below a specified directory?"). Not since the FAQ posting started have I seen a discussion that was as irritating as that discussion about find(1) (although the "What is a wizard?" discussion came close). Until now. The number of unnecessary postings, many of them wrong, about "How to delete a file with ^? chars in the name?" is really, really getting irritating. Can people just *stop* posting, please? And if you *are* going to post about it, then post about the *real* question, which is how to deal with files that have the eighth bit set in characters in their names. In article <1221@kl-cs.UUCP>, jonathan@cs.keele.ac.uk (Jonathan Knight) writes: > Why doesn't anyone suggest 'rm ???H01.b' - assuming that there are no other > file names ending in H01.b which are exactly 8 chars long this will work > fine. Because the symptoms described by the original poster imply very strongly that the files in question have characters in the filenames with their eighth bit set. Under BSD at least, none of the system calls that deal with filenames will accept files that have characters of that sort in that name; frankly, I am puzzled about how the original poster managed to get files of that sort on his disk, because I had to edit the raw disk device to do it. It may be easier under non-BSD versions of Unix. I created a filesystem on a floppy disk, created a zero-length file "Afrep" on the disk filesystem, read the filesystem into a regular file, changed the 'A' in the filename "Afrep" to '\201' ('A' with the high bit set), then wrote my copy of the file back out to the floppy. All this with the floppy fs unmounted, of course. I then tried to fsck the disk device. This is what I got: pit-manager# fsck /dev/floppy ** /dev/floppy ** Last Mounted on /tmp/disk ** Phase 1 - Check Blocks and Sizes ** Phase 2 - Check Pathnames DIRECTORY CORRUPTED I=2 OWNER=jik MODE=40755 SIZE=512 MTIME=Jan 15 00:14 1990 DIR= SALVAGE? no ** Phase 3 - Check Connectivity ** Phase 4 - Check Reference Counts UNREF FILE I=4 OWNER=jik MODE=100664 SIZE=0 MTIME=Jan 15 00:14 1990 RECONNECT? no CLEAR? no ** Phase 5 - Check Cyl groups 3 files, 9 used, 2198 free (14 frags, 273 blocks, 0.6% fragmentation) So, as you can see, fsck doesn't like at all the fact that there is a filename with a character with the high bit set. Ignoring the fact that fsck didn't like the disk, I mounted it anyway (don't try this at home, folks! :-): pit-manager# mount /dev/floppy /tmp/disk pit-manager# cd /tmp/disk pit-manager# ls lost+found ?frep pit-manager# ls -l frep not found (Invalid argument) total 4 drwxr-xr-x 2 root 4096 Jan 15 00:12 lost+found pit-manager# ls -li frep not found (Invalid argument) total 4 3 drwxr-xr-x 2 root 4096 Jan 15 00:12 lost+found pit-manager# rm ?frep rm: frep nonexistent The net result of all of this is that it seems that if there really are characters with the high bit set in filenames on the disk (that would seem to be suggested even more strongly by E-mail correspondence I have had with the person having this problem), the only way to solve them is to either (a) run fsck on the disk and let it fix the corrupted directories and put the unconnected files that result into lost+found on the device (if your fsck doesn't notice directories that are corrupted in this manner, then get a new fsck :-), or (b) unmount the disk and edit the raw disk device using fsdb (or, if you're even more brave, emacs :-) to fix the errant filenames. Now, if you've got another idea for dealing with filenames with characters with their high bit set, I'd like to hear it, and it probably would belong in comp.unix.wizards. If you want to talk more about rm -i and using find and using simple C programs, then please send it to /dev/null! Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8495 Home: 617-782-0710 P.S. In an earlier message on this subject, I said that "ls -li" and "find -inum" could be used to deal with the file. However, if there really are high-bit characters in the file name, that won't work.
bzs@world.std.com (Barry Shein) (01/17/90)
From: jik@athena.mit.edu (Jonathan I. Kamens) > The number of unnecessary postings, many of them wrong, about "How to >delete a file with ^? chars in the name?" is really, really getting >irritating. Can people just *stop* posting, please? And if you *are* >going to post about it, then post about the *real* question, which is >how to deal with files that have the eighth bit set in characters in >their names. Although your heart's in the right place you're missing the point. I would bet that most people who post dumb/repetitive questions are new to the list so they won't see your pleas. I used to like to stand up in front of a class on the first day of the semester, look out at the audience confused and comment "didn't I explain all this stuff *last* year? What's your problem?" Probably some of these questions are unleashed between "frequently asked questions" postings although on USENET these sorts of things are supposed to be archived and somehow the new user nudged toward them. I must admit that such helpful hints are getting so large as to be less than helpful. On my system I have well over 1,000 newsgroups, imagine if even 10% had a few pages of "frequently asked questions" or equivalent, no one would read it, hundreds of pages. It's bulky already with frequently asked questions, emily_postnews, netiquette, group descriptions, etc. Here's an evil idea: Let's put a hook into the mail readers which ignores all postings on unix-wizards which doesn't, oh I dunno, have a subject line ending with a period, or exactly two blank lines at the beginning, something. Then explain this requirement at the end of frequently asked questions... heh heh...:-) -- -Barry Shein Software Tool & Die, Purveyors to the Trade | bzs@world.std.com 1330 Beacon St, Brookline, MA 02146, (617) 739-0202 | {xylogics,uunet}world!bzs