Ugly file name

W. Lee Duncan duncan at diamond.rtp.dg.com
Sat May 20 01:13:20 AEST 1989


In article <448 at hsi86.hsi.UUCP> derek at hsi86.UUCP (Derek Lee-Wo) asks
about removing files whose name starts with a minus.

Two solutions mentioned are using:

	rm - -badfilename

and

	find . -owner badowner -size badsize -exec rm '{}' \;

Also, the easiest method might be:

	rm ./-badfilename


Also, some have mentioned having names with garbage characters in them
(e.g. control chars, MSB set, ...).  Most solutions have suggested
just quoting the bad characters.

In my experience with System V 3B*'s I seem to remember
many cases of bad file names that couldn't be quoted. For example, you
would do an ls, see a garbage file name (perhaps piping the output
of ls to "cat -v" or "od -c") that you wanted to delete.  So, as several
solutions here have suggested, I would type:

	rm -i *		(for example)

And, when "rm" got around to the name, it might output some like:

	rm: remove abc^C^@_?

and I would type "yes".  Then, rm would say something like:

	rm: abc^C^@_: No such file or directory

Now, what to do here.  Some of the methods suggested will still work, namely
using find and some unique combo to identify the file (since find doesn't
use the shell I think).  Or, if you have permission, clri.  What I did
was right a C program to remove files, by inode number, called zap.  Something
like:

    for each file:
	open the directory where the file resides
	scan through the files in that directory until you find the
		one with the right inode number
	remove (possibly with verification from the user) the file

C code is left as an exercise for the reader (I used to hate it when I heard
that!).

Enjoy! (;-)|-< Don't you just hate these smiley faces!
--
W. Lee Duncan, Data General, RTP     - "How can you be two places at once
UUCP: {world}!mcnc!rti!dg-rtp!duncan -  when you're really no place at all"
DOMAIN: duncan at dg-rtp.dg.com         -                Firesign Theatre



More information about the Comp.unix.questions mailing list