[H-GEN] Shell usage...

Craig Eldershaw ce at comlab.ox.ac.uk
Sun Aug 23 06:32:48 EDT 1998


>> Hello everybody - i've screwed up whilst using ftp and created a file that
>> starts with a '-' symbol - how do you kill this file in the shell?
>> 
>
>I've found for strange filenames, you can usually put quotes around
>them, or just starting typing it and hitting tab (assuming bash) should
>finish it and put quotes around it for you.

That will work if you have spaces or semicolons etc that might confuse
the shell (eg 'rm father&son' would be parsed as two commands ('rm
father' and 'son')).  But in this case the shell is not confused, the
option `-' is in fact a single parameter which is being passed to the rm
program.  The problem arises because rm itself is interpreting anything
starting with a - as an option when it was meant to be a file.  So
quoting won't help here.  Either removing the leading - by pre-prending
a ./ or explicitely telling rm that there are not more options for it
(and that all the rest are file names) by adding the -- are the way to go
(as was pointed out previously).

Cheers,
	Craig.





More information about the General mailing list