Operating System - HP-UX
1833748 Members
2689 Online
110063 Solutions
New Discussion

trouble removing a weird file name

 
mike worrell
Regular Advisor

trouble removing a weird file name

HI all,

Someone put a file name like this on our system and I can't remove it, tried rm -i * and it quits when it hits this one.
Here the example, it starts with a - sign.
example -Ptest_test.txt
Any ideas,
Thanks
Mike
8 REPLIES 8
Uday_S_Ankolekar
Honored Contributor

Re: trouble removing a weird file name

Try
rm -- -Ptest_test.txt

-USA..
Good Luck..
Marco Santerre
Honored Contributor

Re: trouble removing a weird file name

have you tried doing
rm ./-Ptest_test.txt
Cooperation is doing with a smile what you have to do anyhow.
A. Clay Stephenson
Acclaimed Contributor

Re: trouble removing a weird file name

Easy,

We need to tell the rm command that there are no more options to process via the '--' argument.

rm -- -Ptest_test.txt
should do the trick.


If it ain't broke, I can fix that.
mike worrell
Regular Advisor

Re: trouble removing a weird file name

thanks to all, that did it.
James R. Ferguson
Acclaimed Contributor

Re: trouble removing a weird file name

Hi Mike:

# rm -- -Ptest_test.txt

...Note the double hyphen. This tells well-behaved Unix commands that there are no more flags (options).

# touch -- -me
# rm -i -- -me

Regards!

...JRF...
Garry Ferguson
Frequent Advisor

Re: trouble removing a weird file name

I know this is really closed
but just to add my penny worth...

Use "ls -ali" to find the file's inode and then
"find . -inum -exec rm {} \;" to remove it.

Garry F
RAC_1
Honored Contributor

Re: trouble removing a weird file name

ls -ali -- to get file's inode no.
then
find . -imum inode_no -exec rm {} \;
There is no substitute to HARDWORK
T G Manikandan
Honored Contributor

Re: trouble removing a weird file name

The best option is using rm --

check the man pages of rm.

Also you can use

rm ./<-filename>