kimcm@ambush.UUCP (Kim Chr. Madsen) (04/20/88)
In article <49968@sun.uucp> limes@sun.uucp (Greg Limes) writes: >In article <670012@hpclscu.HP.COM>, shankar@hpclscu.HP.COM (Shankar Unni) writes: >> Let's say that you managed to create a file called >> "a.*\03\07^q". If you just typed in rm a.*\03\07^q, the *shell* steps in >> and does nasty stuff. I used to have a little util called "erase" around when I was working on a system where you couldn't remove files with 8'th bit set in the filenames nor would ls(1) show the filename properly, so you had to do an od(1) on "." to get the real name. The program had no parameters but checked the current directory for funny filenames and interactively asked the user whether to remove this or that funny file. If anyone interrested I might have the source somewhere...! >Try using "./" before the filename. For instance, if you have a file >called "-rf *" in your current directory, the command "rm './-rf *'" >would get rid of it. Note the single quotes here, too. I would not use this command or propagate its use -- it's too damn dangerous if you forget the single quotes or have them replaced with double quotes! rather would I make a small C-program: main() { unlink("-rf *"); } which would guarantee that at most ONE file would be removed! Kim Chr. Madsen, AmbraSoft A/S, Rojelskaer 15, DK-2840 Holte (Denmark) UUCP: kimcm@ambush.dk, PHONE: +45 2424 111, FAX: +45 2423 090 Though I am not naturally honest, I am so sometimes by chance. -- William Shakespeare
jws@hpcljws.HP.COM (John Stafford) (04/23/88)
Note rm -f './*' is not necessary as rm -f '*' will work just fine (the ''s inhibit expansion of the *). And yes it is dangerous. Using unlink ("-fr *"); in a C program is going to try to unlink a file named -fr * to unlink a file named * in a C program use unlink ("*"); John 'picky picky picky' Stafford