Monday, August 4, 2008

How to delete a file starting with a character "-"

Recently, I tried to delete a file which has a starting "-". The filename is called --ahlong.avi. Unfortunately, running

$ rm -- --ahlong.avi

gave me an error. So how do you delete a file that has a "-" starting character. Well i found out there are a few ways to do this....

$ rm ./--ahlong.avi
or
$ rm -- --ahlong.avi


Both seems to work.

2 comments:

Abah said...

kalau degil jugak, aku biasanya delete guna inode....

# ls -i
(amik inode dia)
# find . -inode [nombor inode] -exec rm {} \;

0xff said...

ce try guna


rm "\--ahwargh.mp3"

escape char.