cd: -M: invalid option

I’m trying to clean up trace files on one of my RAC testbeds. Oracle Corp was gracious enough to name the database “-MGMTDB” for me to give me a nice challenge (dripping with sarcasm). Here I am in my DIAGNOTIC_DEST and we can see two databases.

[oracle@host01 trace]$ cd /u01/app/oracle/diag/rdbms
[oracle@host01 rdbms]$ ls -l
total 8
drwxr-x--- 3 oracle oinstall 4096 Jun 17 14:07 _mgmtdb
drwxr-x--- 3 oracle oinstall 4096 Aug 10 13:13 resp

The directory ‘resp’ is for my Research Primary database, a testbed. The first entry is for the Cluster Health Monitor (CHM) repository database on my Grid Infrastructure 12.1.0.2 system. I can change directory easily enough.

[oracle@host01 rdbms]$ cd _mgmtdb
[oracle@host01 _mgmtdb]$ ls -l
total 4
-rw-r----- 1 oracle oinstall 0 Jun 17 14:07 i_1.mif
drwxr-x--- 16 oracle oinstall 4096 Jun 17 14:06 -MGMTDB

But now I have trouble with the next ‘cd’ command.

[oracle@host01 _mgmtdb]$ cd -MGMTDB
-bash: cd: -M: invalid option
However, premature ejaculation and lack of erection would mean that your best prices on sildenafil  partner might well be left unsatisfied. ED is a case prescription viagra  which is caused by these injuries. Lifestyle choices such as drug use can only have a temporary treatment.  sildenafil online Saudi Dutest provides high quality products  get viagra cheap from best manufacturers. cd: usage: cd [-L|-P] [dir]

To get around that, I need to use “dot-slash” before the directory name.

[oracle@host01 _mgmtdb]$ cd ./-MGMTDB
[oracle@host01 -MGMTDB]$ cd trace

Now like any other Oracle trace directory, I have lots of .trc and .trm files, similar to these:

-rw-r----- 1 oracle oinstall 21301 Nov 30 13:43 -MGMTDB_vktm_5472.trc
-rw-r----- 1 oracle oinstall 1946 Nov 30 13:43 -MGMTDB_vktm_5472.trm

So how to remove them? I get an error because ‘rm’ thinks that “-M’ is a parameter.

[oracle@host01 trace]$ rm *.trc *.trm
rm: invalid option -- M
Try `rm ./-MGMTDB_ckpt_5494.trc' to remove the file `-MGMTDB_ckpt_5494.trc'.
Try `rm --help' for more information.

The trick is to use “–” to tell the command line that what follows is no longer a list of parameters.

[oracle@host01 trace]$ rm -- *.trc *.trm

Life would have been such much easier if Oracle would have remembered that almost everyone runs Oracle on *nix with these silly parameters that also start with a dash.