Operating System - HP-UX
1756552 Members
3262 Online
108848 Solutions
New Discussion юеВ

removing files prefixed with hyphens

 
SOLVED
Go to solution
Paolo_c
Valued Contributor

removing files prefixed with hyphens


I need to remove some files whose names are prefixed with a (single) hyphen..Although I've read various posts on ways to remove them, I'm still not 100% sure whether the answers provided are all applicable /safe to use under my ( Bourne shell) environment.


An example of one of the files I wish to delete is displayed below....

find . -name '-a'
./-a
/test#


I believe I should be able to delete these files using either of the commands displayed below....but just looking for confirmation that
this will work under the Bourne shell...It would also be useful to know whether the -i (interactive) option will work if included in the commands below ?

rm ./-a
rm -- -a

 

 

 

 

3 REPLIES 3
Dennis Handly
Acclaimed Contributor
Solution

Re: removing files prefixed with hyphens

>applicable/safe to use under my (Bourne shell) environment.

 

(I doubt you are using the Bourne shell on HP-UX.  Most likely the Posix shell.)

 

This problem has nothing to do with the shell.  A "-" is not special to the shell.

The problem is with each command and how it parses options and what's an option.

 

>I believe I should be able to delete these files using either of the commands displayed below but just looking for confirmation that this will work under the Bourne shell..

 

Why not create a new directory and just try them?

 

>whether the -i (interactive) option will work if included in the commands below?


Sure, since you are removing one file, not zillions.

Paolo_c
Valued Contributor

Re: removing files prefixed with hyphens

Thanks for that. I followed your suggestion and tested commands against files in a new directory and it worked fine.
Dennis Handly
Acclaimed Contributor

Re: removing files prefixed with hyphens

>Thanks for that.

 

If you are happy with your answers, please also click on the Kudos start on the post with the answer.