Ugly file name
Guy Harris
guy at auspex.auspex.com
Wed May 17 03:57:05 AEST 1989
>This doesn't work for filenames that start with a minus. eg -badfile
>Anyone know how to erase such files with whipping up a short C program?
Yes, I think just about *anybody* reading any of these groups who is
familiar with the "unlink" system call can do it trivially.
However, there are better ways to remove "-badfile" as well. Both the
BSD and S5 versions (S5R3 and later, and least, and, I suspect, S5R2 and
maybe earlier as well) have flags to say "nothing after this is a flag,
even if it begins with a "-"; in the BSD version, the flag is "-", and
in the S5 version, the flag is "--" (since the S5R3 version, and
possibly other versions, use "getopt", which handles "--" for the
program using it). So, you can do
bsd$ rm - -badfile
s5$ rm -- -badfile
If your "rm" doesn't have something like that, you can do
loser% rm ./-badfile
More information about the Comp.unix.questions
mailing list