Operating System - HP-UX
1834931 Members
2543 Online
110071 Solutions
New Discussion

Re: Problem remove file with special character

 
SOLVED
Go to solution
Melvin Thong
Advisor

Problem remove file with special character

Hi,

We had accidently created a file with "-" character in front of a file name.

Eg) A file name called "-B", we couldn't find a way to delete this file. Even when we tried to use the following methods, but none of them works:
# rm "-B"
# rm "\-B"

Could anyone suggest the method to overcome the above problem? Thank you in advance.


Regards,
Melvin
7 REPLIES 7
Robert-Jan Goossens
Honored Contributor
Solution

Re: Problem remove file with special character

Hi,

# rm -- -b
or
# rm -- "-b"

Robert-Jan.
BFA6
Respected Contributor

Re: Problem remove file with special character

Hi Melvin,

One way I've got rid of files with special characters in the past is to first of all make sure I had a good backup then done rm -i * and answered yes to the file I want to get rid of, no to others.

There is probably a "safer" way of doing it.

Regards,

Hilary
Ramkumar Devanathan
Honored Contributor

Re: Problem remove file with special character

Hi Melvin,

Run this -

$ rm -- -B

-- signifies end of options.

- ramd.
HPE Software Rocks!
Donald Kok
Respected Contributor

Re: Problem remove file with special character

Hi Melvin,

In these case I use the CDE-filemanager, and remove it with the mouse. Easy and simple.

Greetzz
Donald
My systems are 100% Murphy Compliant. Guaranteed!!!
Tore_1
Regular Advisor

Re: Problem remove file with special character

ls -li

This will give you the inum, for instance inum 980.

Then

find . -inum 980 -exec rm -i {} \;

john korterman
Honored Contributor

Re: Problem remove file with special character

Hi,
# rm ./-B
should also work

regards,
John K.
it would be nice if you always got a second chance
Tim Sanko
Trusted Contributor

Re: Problem remove file with special character

If the name is significant i.e the only one with the same starting letter

rm *B*

TJS