> If I create a file as below and try to read it or delete it, gives
> problem saying "Unrecognized option".
>
> cat > ---abc
> aaldknfkdnadsf
> asldknf;alksdfn;asdf
> ^d
>
> To delete this file, it has to be in a directory and then we have to
> go to it's parent directory and forcefully remove (rm -rf directory)
> the directory. If this file is created under '/' then, we can't
> delete this file at all.
This is an almost standard answer to your commonly asked question.
As you noted since the file name begins with a '-' it looks like an
option to the command. You need to force it to not look like an
option. Put a ./ in the front of it. Or give it the full file name
path. Or tell the command you are through with options by using the
double dash to end all option processing. This is common to most
traditional UNIX commands.
rm ./-stuff
rm /full/path/-stuff
rm -- -stuff
The reason you can create the file without this issue is that you are
using shell redirection which does not use options at all.
Bob