System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

remove a file with a '-' at the start of its name

 
SOLVED
Go to solution
The Gunners
Regular Advisor

remove a file with a '-' at the start of its name

Hi People ,
HP/UX specifically here. One of App Team by error created a file called '-sh.err' , we are trying to delete it , and it wont do anything for us ? The problem is the '-' at the beginning of the file , if you try rm -i filename , it comes back with error , also even a simple ls -al of the file , and it bounces back an error Any tips on how to remove ? Thanks
7 REPLIES
Patrick Wallek
Honored Contributor

Re: remove a file with a '-' at the start of its name

Use wildcards.

# rm -i *.err

Answer no until you get to the one you want.
Robert-Jan Goossens_1
Honored Contributor
Solution

Re: remove a file with a '-' at the start of its name

Hi Davey,

Try

# rm -- -filename

Regards,
Robert-Jan
The Gunners
Regular Advisor

Re: remove a file with a '-' at the start of its name

Robert , thats the one , thats done the trick. Thanks everyone
TTr
Honored Contributor

Re: remove a file with a '-' at the start of its name

This is a classic one.

rm -i -- -xyz123

The "--" indicates that whatever follows is no longer an option so the -xyz123 is treated as a filename and not as an option.
The Gunners
Regular Advisor

Re: remove a file with a '-' at the start of its name

File deleted successfully!

Re: remove a file with a '-' at the start of its name

Or the tried and true relative or absolute path:
rm -i ./-sh.err
The Gunners
Regular Advisor

Re: remove a file with a '-' at the start of its name

nice one , thanks Denis