Linux system delete command


foreword

In the linux system, we will use the rm command to delete files or directories, but in actual use, we will use it with some parameters or with some other commands to achieve specific functions.

1. Grammar

rm command syntax:

rm [options] name...

2. Parameter description

Parameter introduction:

-i 删除前逐一询问确认。
-f 即使原档案属性设为只读,亦直接删除,无需逐一确认。
-r 将目录及以下之档案亦逐一删除。

3. Examples of common operations

Example 1: Delete files (with confirmation reminder).

rm a.txt

Example 2: Forcibly delete files.

rm -f a.txt

Example 3: Forcibly delete directories and files recursively, the text of the following command is a directory.

rm –rf text

Example 4: Use the find command to delete all files in the test directory.

find test -type f -exec rm {
    
    } \;

Example 5: Use the find command to delete files modified 30 days ago in the test directory.

find test -mtime +7 -exec rm {
    
    } \;

Example 6: Use the find command to delete files larger than 10M in the test directory

find test -size +10M - rm {
    
    } \;

Summarize

Workd document download address: Linux system delete command

Guess you like

Origin blog.csdn.net/ma286388309/article/details/129275428