rm Command:

The rm command is used to remove/delete a file in Linux system. rm commands remove the files without any confirmation so you make sure before deleting files. This command does not delete directories by default. For using this command using the given command

Syntax:

$ rm filename

rm commands with Example:

Removing multiple files of similar extension:

If you want to remove the multiple files of similar extension then you can use the rm command follow the given syntax.

Syntax:

$ rm *.log

Removing Single file:

You can use the rm command to remove a file.

Syntax:

$ rm filename;

$ rm my.txt;

Removing Multiple File:

If you want to remove multiple files at same time than use the given command.

Syntax:

$ rm file1 file2 file3

$ rm abc.txt myfile.txt index.txt

If you want to remove files with confirmation massage for surely delete files than use the – i option with rm command. – i option is refers to as “inquiry” used to prompt massage no/yes before deleting files .

Syntax:

$ rm – i file1 file2

Removing one Directory:

You can use the rm command with – r option for remove the directory. –r option is used to delete files recursively in the directory.

Syntax:

$ rm – r directory name

$ rm – r mydir

Removing Multiple Directories:

You can delete multiple directories at same time via using the given commands.

Syntax:

$ rm – r directory1 directory2 directory 3

Option of rm command:

We define the option that you can use with the rm command.

· - i : this option is used to prompt before deleting files or directory.

· -r, - R : this option is used to delete directory and content recursively.

· - v: option for verbose mode.

· - f: this option is used to delete without any prompt.

· - I: this option is used for prompting before removing for multiple files.

· - d: this option is used to delete directory.
Author
Jaishree
Views
1,867
First release
Last update
Rating
0.00 star(s) 0 ratings
Top