Find of linux command

Definition: The
find command is mainly used to find matching files under the specified directory. It supports regular expressions.

Main parameters
:! Reverse
-a is equivalent to and take intersection
-o is equivalent to or take union
-mtime wait time
-atime access data
-ctime creation time
-maxdepth search depth
-name search by file name
-iname search by file name (ignoring case )
-Type search by file type
-size search by file size

The following are examples of the above parameters:

find ./ -name " acrosspm " Find files or directories that contain the acrosspm keyword in the name of the file or directory under the current directory.
Find ./! -name " acrosspm " Find files or directories that do not contain the acrosspm keyword in the name of the file or directory in the current directory

find ./ -type f -name " acrosspm " In the current directory, only find files whose names contain the acrosspm keyword

find ./ -size +1M Find files larger than 1M under the current directory

find ./ -maxdepth 1 -name "*.log" Find files with a depth of 1 (only the current directory, not subdirectories) and end with log

find ./ -name "a" -o -name "b" find a or b file

find ./ -name "test.txt" -mtime +7 Find test.txt files modified 7 days ago
find ./ -name "test.txt" -mtime -7 Find test.txt files modified 7 days

Find common command formula collocation:
find ./ -name "test.txt" -exec rm {}\

find ./ -name "text.txt"|xargs rm -f This place xargs means to put the found matching results on one line, and then rm.

find ./ -name "test.txt" -type f |xargs -i cp {} /home/acrosspm/

Note: find ./ and find ./difference./ do not include the current directory

Guess you like

Origin blog.51cto.com/15013163/2553749