[Linux] rm command: delete files/folders


1. Delete files/folders: rm command

rm is a powerful delete command that permanently deletes specified files or directories from the file system.

When using the rm command to delete files or directories, the system will not generate any prompt information. The basic format of this command is:

rm [选项] 文件或目录

options:

  • -f: Force deletion (force), contrary to the -i option, use -f, the system will not ask, but directly delete the target file or directory.
  • -i: Just the opposite of -f, before deleting a file or directory, the system will give a prompt message, using -i can effectively prevent accidentally deleting useful files or directories.
  • -r: Recursive deletion, mainly used to delete directories, can delete the specified directory and all its contents, including all subdirectories and files

Second, delete the file (that is, the file is deleted)

Single deletion: rm -f + filename

rm -f  2018_12_26.stderrout.log.060121612 --执行完成即将这个文件删除

3. Delete the folder

rm -rf + 路径/目录名

Forcefully delete a folder and its subfiles.


Four, pay attention

The rm command is a destructive command because the rm command permanently deletes a file or directory, which means that if the file or directory is not backed up, once it is deleted using the rm command, it cannot be recovered. Therefore, Especially when using the rm command to delete directories, be careful.


reference link

  1. Linux rm command: delete a file or directory
  2. Linux delete file command

Guess you like

Origin blog.csdn.net/weixin_44211968/article/details/123966263