rm/del

Syntax

rm[-q]file/directory[file/directory...]

Description

Deletes one or more files or directories. The del command is an internal alias for this command.

Options

-q

Deletes in quiet mode, without displaying a confirmation prompt.

file

Specifies the file name to be deleted. Wildcards are permitted.

directory

Specifies the directory to be deleted. Wildcards are permitted.

Usage

If the target is a directory, this command deletes the directory, including all its subdirectories. This command is not allowed to redirect a file whose parent directory (or the file itself) is being deleted.

Removing a read-only file or directory results in a failure. Removing a directory containing one or more read-only files results in a failure. If an error occurs, rm exits immediately, and later files or directories are not removed.

You cannot remove a directory when the current directory is itself or its subdirectory. If the file specified for deletion contains wildcards, you are not prompted for confirmation.

You cannot remove the root directory, or the current directory or its ancestor.

Examples

Attempting to remove multiple directories at one time when directories cannot be found (causing the command to exit):

fs0:\> ls test
Directory of: fs0:\test 

	06/18/01 	01:01p <DIR> 			512 .
	06/18/01 	01:01p <DIR> 			0 ..
	06/19/01 	12:59a <DIR> 			512 temp1
	06/19/01 	12:59a <DIR> 			512 temp2 
				0 File(s) 0 bytes 
				4 Dir(s)

fs0:\> rm test\temp11 temp2
rm/del: Cannot find 'fs0:\test\temp11' - Not Found 

To remove multiple directories with wildcards:

fs0:\> rm test\temp* 
rm/del: Remove subtree 'fs0:\test\temp1' [y/n]? y 
removing fs0:\test\temp1\temp1.txt 
- [ok]
removing fs0:\test\temp1\boot\nshell.efi
- [ok]
removing fs0:\test\temp1\boot 
- [ok]
removing fs0:\test\temp1 
- [ok] 
rm/del: Remove subtree 'fs0:\test\temp2' [y/n]? y
removing fs0:\test\temp2\temp2.txt 
- [ok] 
removing fs0:\test\temp2 
- [ok]
      

Attempting to remove a directory containing a read-only file, causing an error prompt:

fs0:\> attrib +r test\temp1\readme.txt 
A R fs0:\test\temp1\readme.txt 

fs0:\> rm test\temp1 
rm/del: Cannot open 'readme.txt' under 'fs0:\test\temp1' in 
writable mode
- [error] - Access Denied 
Exit status code: Access Denied