Wednesday, November 14, 2007

Create a file named -rf and then delete it

Have you ever tried to create a file named -rf. If you want to have lots of fun, just tell your friend to create and delete a file named -rf

I bet they will have hard time creating and deleting it (unless he/she is a UNIX guru or has already done it before). I have seen people afraid of even deleting this file because -rf is a recursive delete attribute for rm command and most people think 100 times before using -rf. So, if you are playing prank on someone they will be even more afraid of using it. LOL

So, lets start the fun.

To create the file named -rf. (Learned from my colleague Jason Hamilton)

cat /dev/null > -rf


this will create -rf file in your current directory

There are two ways that I know of to delete this file.

rm -- "-rf"

rm ./-rf



Try it and bewilder your friends.
Hope you enjoyed it.
Cheers,

Rakesh Gupta

No comments: