Linux rm command

rm removes each specified files and directories. By default rm does not remove the directories.

Syntax:

m [OPTION]… FILE…

Note: If the -I or –interactive=once option is given, and there are more than three files or the -r, -R, or –recursive are given, then rm prompts the user for whether to proceed with the entire operation. If the response is not affirmative, the entire command is aborted.

Caution!!!Think 1000 times to run “rm -rf“. A man was performed this command, then his company is no more. See Man accidentally ‘deletes his entire company’ with one line of bad code

rm Examples:

To delete a file with prompt before every removal.

[root@localhost k2schools]# rm -i test.txt
rm: remove regular file `test.txt’? y
[root@localhost k2schools]#

To delete file without prompt.

Linux rm command1

To delete all *.txt files with prompt.

rm *.txt

To delete all files without prompt.

rm -f *.txt

To remove all files in the current working directory with prompt.

rm *

To remove all files in the current working directory without prompt.

rm -f *

To delete the directory with prompt.

rm -r class2

To delete the directory without prompt.

rm -rf class2

Linux rm command2

Options:

Linux rm command

Powered by k2schools
Skip to toolbar