rm The command is used to delete a specified file or directory , This command is a dangerous one , Be sure to check again and again before operation , Then follow the steps .
By default , It can't delete the directory directly , Need to match options to delete . When using -r or -R Option to execute rm when , It recursively removes any matching directories , And their subdirectories and all the files contained in them .
If you need to delete multiple files by matching file extensions ,rm The command needs to use -i Options . When using this option , The system will prompt you one by one if you want to delete the file , When you type y And press Enter key , The file will be deleted , conversely , The file will not be deleted .
rm [ Options ] File or directory mv [options] FILE DIRECTORY
-d：# Change the number of hard connections of the directory to be deleted to 0, Delete this directory -f：# Force deletion of files or directories -i：# Prompt the user whether to delete before deleting -r or -R：# Recursive processing --preserve-root：# No recursive operation on the root ; -v：# Display the detailed execution process of the instruction .
Delete file test.txt And documents test1.txt Go ahead to confirm whether to delete , The delete command is as follows
[root@test ~]# rm -i test.txt test1.txt rm: remove regular file ‘test.txt’? y rm: remove regular file ‘test1.txt’? y # Input y confirm deletion
Delete /test All directories under the directory , And do not confirm before deleting . The delete command is as follows .
[root@test ~]# rm -rf /test/ [root@test ~]# ls /test ls: cannot access /test: No such file or directory
This article is from WeChat official account. - The road of technology for migrant workers （jishuroad）
The source and reprint of the original text are detailed in the text , If there is any infringement , Please contact the firstname.lastname@example.org Delete .
Original publication time ： 2021-01-16
Participation of this paper Tencent cloud media sharing plan , You are welcome to join us , share .