rm

Purpose

Deletes the specified Oracle ASM files and directories.

Syntax and Description

rm [-f|-r] pattern [pattern...]

Table 10-39 lists the syntax options for the rm command.


Table 10-39 Options for the rm command

Option Description

-r

Recursively deletes files and subdirectories.

-f

Deletes files and subdirectories without prompting for confirmation.

pattern

Name of a file, directory, or wildcard pattern.


If pattern is a file or alias, then the rm command can delete the file or alias only if it is not currently in use. If pattern is a directory, then the rm command can delete it only if it is empty (unless the -r flag is used) and it is not a system-generated directory. If pattern is an alias, then the rm command deletes both the alias and the file to which the alias refers. To delete only an alias and retain the file that the alias references, use the rmalias command.

Note:

When you delete all of the files in a system-created directory, the directory is removed. If the parent directories are empty, all of the parent directories are also removed.

pattern can contain wildcard characters. See "Wildcard Characters".

If you use a wildcard, the rm command deletes all of the matches except nonempty directories, unless you use the -r flag. To recursively delete, use the -r flag. With -r option you can delete a nonempty directory, including all files and directories in it and in the entire directory tree underneath it. If you use the -r flag or a wildcard character, then the rm command prompts you to confirm the deletion before proceeding, unless you specify the -f flag.If a wildcard character matches an alias or a system-generated file that has an alias, then both the alias and the system-generated file that it references are deleted. When using the -r flag to delete an alias that matches a wildcard pattern, either the alias or the system-generated file that has an alias must be present in the directory in which you run the rm command.

For example, if you have a user alias, +data/dir1/file.alias that points to +data/orcl/DATAFILE/System.256.146589651, then running the rm -r +data/dir1 command removes the +data/dir1/file.alias and +data/orcl/DATAFILE/System.256.146589651.

Example

The following are examples of the rm command. The first example deletes the myexamples.bak file. The second example removes the subdir2 directory and its contents.

Example 10-49 Using the ASMCMD rm command

ASMCMD [+data/orcl/datafile] > rm myexamples.bak

ASMCMD [+data] > rm -r subdir2
You may delete multiple files and/or directories. 
Are you sure? (y/n) y