an rm question

Bob Goudreau goudreau at xyzzy.UUCP
Mon Apr 18 15:05:20 AEST 1988


In article <670012 at hpclscu.HP.COM> shankar at hpclscu.HP.COM (Shankar Unni) writes:
>We had the same problem frequently when people would create files called,
>for instance "-b", and rm would choke (-b: illegal option!). The solution
>was (a) rm -- -b (the -- terminates the option list, IN MANY IMPLEMENTATIONS),
>or (b) rm nonexistentfile -b or (c) /etc/unlink -b (for superusers only).

The problems with these solutions are:  (a) is non-portable; (b) is a kludge;
and (c) is just unnecessarily harsh on your file system.

A cleaner and more general solution to this problem can be had by simply
thinking about the names by which a given file can be referenced.  That's
right, "names" not "name".  In particular, "./-b" will always do the trick.
There are an infinitude of other ways to refer to the offending file
that don't begin with "-", such as "/usr/foo/-b" (or whatever one of its full
pathnames may be), or "../foo/-b", or "././-b" or ....

-- 
	Bob Goudreau
	Data General Corp.,  62 Alexander Drive,
	Research Triangle Park, NC  27709
	(919) 248-6231
	{ihnp4, seismo, etc.}!mcnc!rti!xyzzy!goudreau
	goudreau at dg-rtp.dg.com



More information about the Comp.unix.wizards mailing list