Detailed explanation of Linux commands find

  
        

Action

Search for files


Format

find pathoption [-print] [-exec -ok command] {} \\

The default search path is the current path

The default is -print, output to standard output

Execute the command command for the found file

option is the search condition
>


Main Parameters

-name filename

Restricted File Name

-user username

By File Owner Search

-group groupname

Find by group

-mtime -n +n

Find by file change time, -n means n days Within, +n means n days ago

-atime -n +n

Check by file access time

-ctime -n +n

Find by file creation time

-nogroup

-nouser

-type

Search by file type

-size n< Br>

-depth

Search for the directory before finding the subdirectory

-follow

If you encounter a symbolic link file, trace the file pointed to by the link< Br>

-prune

Ignore a file

-o

Logic Or

-a

logic

!

Logic No

\\( \\)

Escape, can include search criteria



Example

Find all common files in the current directory

find .-type f -exec ls -l {} \\;

Find the change time in the home directory at 5 Files from the day before and delete them

find /home-mtime +5 -exec -ok rm {} \\;

Query the files modified today

find /- Mtime -1 -exec ls -l {} \\;

Query the file modified today and prompt whether to display

find /-mtime -1 -ok ls -l {} \\;< Br>

Find files smaller than 100k and display

find /home-size -100k -exec ls -l {} \\;

Find all files with suffix .txt
>

find ~-name "*.txt" -ok ls -l {} \\;

Copyright © Windows knowledge All Rights Reserved