ljcummings@poppy.uwaterloo.ca () (05/28/91)
Hi! This is a stupid question I know.. but somehow I've created a file called !* in my bin directory. How do I get rid of it? I've tried placing it in quotes (single and double) and mv'ing it to a new filename.. nothing seems to work. ====== Script started on Mon May 27 18:49:41 1991 @@_temp: Command not found. _temp: Undefined variable. % pwd % ls -l total 3 -rw------- 1 ljcummings 0 Apr 16 15:31 !* -rwx------ 1 ljcummings 142 Apr 16 15:30 arm -rw------- 1 ljcummings 1060 Apr 24 15:17 longrun.c -rw------- 1 ljcummings 0 May 27 18:49 test % rm !* rm -l rm: unknown option letter 'l' % rm '!*' rm '-l' rm: unknown option letter 'l' % rm "!*" rm "'-l'" rm: '-l': No such file or directory % mv !* filename mv "'-l'" filename mv: '-l': Cannot access: No such file or directory % mv '!*' filename mv '"'-l'" filename' filename mv: "-l" filename: Cannot access: No such file or directory % mv "!*" filename mv "'"'-l'" filename' filename" filename mv: '-l filename' filename: Cannot access: No such file or directory % exit % script done on Mon May 27 18:51:25 1991 I don't normally read this group, so e-mail will be preferred, (though I'll check here anyways.). Thanks muchly! James cummings ljcummings@poppy.waterloo.edu
jc@raven.bu.edu (James Cameron) (05/28/91)
>>>>> On 27 May 91 22:56:30 GMT, ljcummings@poppy.uwaterloo.ca said: ||> Originator: ljcummings@poppy.waterloo.edu ||> Hi! This is a stupid question I know.. but somehow I've created a file ||> called !* in my bin directory. How do I get rid of it? [...deleted script of attempts at removing the file '!*'...] ||> James cummings Since '!' is a special character it needs to be escaped. The solution to your problem is: % rm '\!*' That is all there is to it. You should take a look at bourne and c shell books; or check the man pages under sh(1) and csh(1). Hope that helps! jc -- -- James Cameron (jc@raven.bu.edu) Signal Processing and Interpretation Lab. Boston, Mass (617) 353-2879 ------------------------------------------------------------------------------ "But to risk we must, for the greatest hazard in life is to risk nothing. For the man or woman who risks nothing, has nothing, does nothing, is nothing." (Quote from the eulogy for the late Christa McAuliffe.)
subbarao@phoenix.Princeton.EDU (Kartik Subbarao) (05/28/91)
In article <1991May27.225630.18310@watdragon.waterloo.edu> ljcummings@poppy.uwaterloo.ca writes: > > Hi! This is a stupid question I know.. but somehow I've created a file >called !* in my bin directory. How do I get rid of it? > >I've tried placing it in quotes (single and double) and mv'ing it to a >new filename.. nothing seems to work. > >====== > >Script started on Mon May 27 18:49:41 1991 >@@_temp: Command not found. >_temp: Undefined variable. >% pwd >% ls -l >total 3 >-rw------- 1 ljcummings 0 Apr 16 15:31 !* >-rwx------ 1 ljcummings 142 Apr 16 15:30 arm >-rw------- 1 ljcummings 1060 Apr 24 15:17 longrun.c >-rw------- 1 ljcummings 0 May 27 18:49 test >% rm !* >rm -l >rm: unknown option letter 'l' >% rm '!*' >rm '-l' > I don't normally read this group, so e-mail will be preferred, (though > I'll check here anyways.). Thanks muchly! The problem is that ! substitution occurrs even within single quotes. You need to escape the !, like this: % rm '\!8' -Kartik -- internet% ypwhich subbarao@phoenix.Princeton.EDU -| Internet kartik@silvertone.Princeton.EDU (NeXT mail) SUBBARAO@PUCC.BITNET - Bitnet
subbarao@phoenix.Princeton.EDU (Kartik Subbarao) (05/28/91)
In article <azfOkbn3PtjME@idunno.Princeton.EDU> subbarao@phoenix.Princeton.EDU (Kartik Subbarao) writes: >% rm '\!8' Err, make that : % rm '\!*' (sorry, I was too lazy to cancel) -Kartik -- internet% ypwhich subbarao@phoenix.Princeton.EDU -| Internet kartik@silvertone.Princeton.EDU (NeXT mail) SUBBARAO@PUCC.BITNET - Bitnet
heinz@cc.univie.ac.at (05/28/91)
In <29957@hydra.gatech.EDU> gt5223b@prism.gatech.EDU (Doug Berkland) writes: >Along the lines of hard to remove files... is there any way to remove >a file beginning with a - ? Using \- doesn't get it... any ideas? [Signature deleted] No problem <grin>. $ echo > -a $ ls -l total 54 -rw-r--r-- 1 heinz 1 May 28 09:14 -a -rwxr-xr-x 1 heinz 24576 May 13 1990 b -rw-r--r-- 1 heinz 311 May 13 1990 b.c -rwxr-xr-x 1 heinz 24576 May 13 1990 c -rw-r--r-- 1 heinz 139 May 13 1990 c.c drwxr-xr-x 3 heinz 3072 May 27 12:38 junk1 $ rm - -a $ ls -l total 53 -rwxr-xr-x 1 heinz 24576 May 13 1990 b -rw-r--r-- 1 heinz 311 May 13 1990 b.c -rwxr-xr-x 1 heinz 24576 May 13 1990 c -rw-r--r-- 1 heinz 139 May 13 1990 c.c drwxr-xr-x 3 heinz 3072 May 27 12:38 junk1 $ ^D Generally, a single '-' on the command line signals the end of the option list. There may be programs where this trick doesn't work.When in doubt, just try it.. Greetings, HH -- -------------------------------------------------------------------------------- ---/ Heinz M. Herbeck / Trust me, I know / /- --/ heinz@sophie.pri.univie.ac.at / what I'm doing ! / /-- -/ Vienna University, Austria / (Sledge Hammer) / /--- --------------------------------------------------------------------------------
msf@wren.cs.rmit.OZ.AU (Michael Fuller) (05/28/91)
In <29957@hydra.gatech.EDU> gt5223b@prism.gatech.EDU (Doug Berkland) writes: >Along the lines of hard to remove files... is there any way to remove >a file beginning with a - ? Using \- doesn't get it... any ideas? I really hate to say "RTFM", but...! I quote from the manual entry for "rm": NAME rm, rmdir - remove (unlink) files or directories SYNOPSIS rm [ -f ] [ -r ] [ -i ] [ - ] file ... [deleted] The null option - indicates that all the arguments following it are to be treated as file names. This allows the specif- ^^^^^^^^^^^^^^^^^^^^^^^ ication of file names starting with a minus. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ !!!!!!! Michael Fuller _____________________________________________________________________________ Key Centre for Knowledge Based Systems, RMIT, Australia. ACSNET: msf@goanna.cs.rmit.OZ BITNET: msf%goanna.cs.rmit.OZ.AU@relay.cs.net INTERNET: msf@goanna.cs.rmit.OZ.AU UUCP: ..!uunet!goanna.cs.rmit.OZ.AU!msf
rearl@watnxt3.ucr.edu (Robert Earl) (05/28/91)
Please, let's not rehash a FAQ that's beaten to death every few months. This is in the comp.unix.questions FAQ. Using "-" or "--" as an option is not the best solution because of the fact that not all programs recognize it. Please don't help spread partially correct or faulty information. -- ______________________________________________________________________ \ robert earl / "Love is a many splintered thing" rearl@watnxt3.ucr.edu \ --Sisters of Mercy rearl@gnu.ai.mit.edu /
stevel@Autodesk.COM (Steve Litras) (05/28/91)
In article <1991May27.225630.18310@watdragon.waterloo.edu> ljcummings@poppy.uwaterloo.ca writes: > > Hi! This is a stupid question I know.. but somehow I've created a file >called !* in my bin directory. How do I get rid of it? Try: rm \!\* That should do it. It worked for me. (csh) Steve -- /\ "When You look into the mirror you can see it. The face of danger, //\\ ferocious energy, barbaric brute strength, savage vitality, and ///\\\ intense vital sensuality. That's your animal." - Steve Vai. ********Steve Litras*****stevel@autodesk.com*****(415)332-2344x2869********
dwestlan@axion.bt.co.uk (Dave Westland) (05/28/91)
In article <29957@hydra.gatech.EDU>, gt5223b@prism.gatech.EDU (Doug Berkland) writes: |> Along the lines of hard to remove files... is there any way to remove |> a file beginning with a - ? Using \- doesn't get it... any ideas? A file called "-name" can be removed by the command : rm - -name The first "-" tells rm to take the argument (very) literally. *-------------------------------------------------------* | DAVID WESTLAND | | BT Laboratories, Martlesham Heath, | | Ipswich. IP5 7RE U.K. | | Email : dwestlan@axion.bt.co.uk | | Tel. : (0473) 642156 Fax : (0473) 643019 | *-------------------------------------------------------* ``Swike him centurion, vewy wuffly!!'' -- L of B ---
jimr@hp-lsd.COS.HP.COM (Jim Rogers) (05/29/91)
The reason you are having trouble with files beginning with "-" is that this character is used by the rm command to signify an option. It is specifically excluded as a valid first character for a file name, as far as the "rm" command is concerned. What you need is an rm-like command which has no options. The following short peice of C code will do the trick. I called it dumbrm because it is not smart enough to have any options. /************************************************************************* * This program will remove a file with any character in the file name * because it has no options. **************************************************************************/ #include <stdio.h> main(argc, argv) int argc; char *argv[]; { int count; char answer[20]; for(count = argc - 1; count > 0; count--) { fprintf(stderr,"Remove %s ? ", argv[count]); gets(answer); if (answer[0] == 'y' || answer[0] == 'Y') { if (unlink(argv[count]) != 0) { perror(argv[0]); } } } } Jim Rogers Hewlett-Packard Company Any opinion expressed or implied by this message are the sole responsibility of the individual(s) above named and have no connection with any opinion, real or imagined, expressed by my employer or any living individual.
Dan_Jacobson@ATT.COM (05/29/91)
>>>>> On 28 May 91 22:46:23 GMT, jimr@hp-lsd.COS.HP.COM (Jim Rogers) said:
Jim> The reason you are having trouble with files beginning with "-"
Jim> is that this character is used by the rm command to signify an
Jim> option. It is specifically excluded as a valid first character
Jim> for a file name, as far as the "rm" command is concerned.
Jim> The following short peice of C code
When
$ rm some_nasty_file_name
fails, I usually just do
$ rm ./some_nasty_file_name
subbarao@phoenix.Princeton.EDU (Kartik Subbarao) (05/29/91)
In article <27620012@hp-lsd.COS.HP.COM> jimr@hp-lsd.COS.HP.COM (Jim Rogers) writes: >What you need is an rm-like command which has no options. [unneeded C - code deleted] This is really getting too silly. I hope that you were joking. I can understand that sometimes simple questions (even FAQ questions) can appear in this newsgroup, and that's okay, but why do they have to be bombarded upon with these many replies??? -Kartik -- internet% whoami subbarao@phoenix.Princeton.EDU -| Internet kartik@silvertone.Princeton.EDU (NeXT mail) SUBBARAO@PUCC.BITNET - Bitnet
miquels@htsa.htsa.aha.nl (Miquel van Smoorenburg) (05/30/91)
In article <1991May28.153437@axion.bt.co.uk%> dwestlan@axion.bt.co.uk (Dave Westland) writes: %> %>In article <29957@hydra.gatech.EDU>, gt5223b@prism.gatech.EDU (Doug Berkland) writes: %>|> Along the lines of hard to remove files... is there any way to remove %>|> a file beginning with a - ? Using \- doesn't get it... any ideas? %> %> A file called "-name" can be removed by the command : %> %>rm - -name %> %> The first "-" tells rm to take the argument (very) literally. %> | DAVID WESTLAND | %> | Email : dwestlan@axion.bt.co.uk | AAAAAAAAAAAAARRRRRRRRRRRRGGGGGGGGGGGGGHHHHHHHHHHHHHHHH!!!!!!!! rm ./-name !!!! Miquel. -- --- % Miquel van Smoorenburg, Baljuwstraat 20, 2461 SL Langeraar, Holland % % miquels@drinkel.nl.mugnet.org miquels@maestro.htsa.aha.nl % % God is real, unless declared integer.. %
sow@cad.luth.se (Sven-Ove Westberg) (06/11/91)
In article <27620012@hp-lsd.COS.HP.COM> jimr@hp-lsd.COS.HP.COM (Jim Rogers) writes: | |What you need is an rm-like command which has no options. | |The following short peice of C code will do the trick. I called it dumbrm |because it is not smart enough to have any options. | Why didn't your program works on a file name with spaces in it :-) :-) :-) :-) :-) :-) ??? Hint what did the shell do? And what did you do with the command line? Sven-Ove Westberg, CAD, University of Lulea, S-951 87 Lulea, Sweden.