Home  >  Article  >  Operation and Maintenance  >  What is the usage of find in linux

What is the usage of find in linux

WBOY
WBOYOriginal
2021-12-27 14:14:4018553browse

In Linux, the find command is used to find files in the specified directory. The syntax is "find specified directory specified rule"; when using this command without setting any parameters, the command will search in the current directory. Subdirectories and files, and display all found subdirectories and files.

What is the usage of find in linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

What is the usage of find in Linux

The Linux find command is used to find files in the specified directory. Any string preceding the parameter will be treated as the name of the directory to be searched. If you use this command without setting any parameters, the find command will search for subdirectories and files in the current directory. And all found subdirectories and files will be displayed.

The syntax is:

find   path   -option   [   -print ]   [ -exec   -ok   command ]   {} \;

where

find determines path and expression according to the following rules. The first part on the command line - ( ), ! Part is path, followed by expression. If path is an empty string, the current path is used. If expression is an empty string, -print is used as the default expression. There are as many as twenty or thirty options that can be used in

expression. Only the most commonly used ones are introduced here.

-mount, -xdev: Only check files in the same file system as the specified directory, avoid listing files in other file systems

-amin n: In the past n minutes Read

-anewer file: File that was read later than file file

-atime n: File that was read in the past n days

-cmin n: Modified in the past n minutes

-cnewer file: File newer than file file

-ctime n: File modified in the past n days

-empty: empty file -gid n or -group name: gid is n or group name is name

-ipath p, -path p: file whose path name matches p, ipath will Ignore case

-name name, -iname name: File name matching name. iname will ignore case

-size n: The file size is n units, b represents a block of 512 bytes, c represents the number of characters, k represents kilo bytes, and w is two bytes.

-type c: The file type is c.

d: Directory

c: Font installation file

b: Block installation file

p: Named storage array

f: General file

l: Symbolic link

s: socket

-pid n: File whose process id is n

You can use () Separate the expressions and use the following operations.

exp1 -and exp2

! expr

-not expr

exp1 -or exp2

exp1, exp2

Examples are as follows:

List all files with the .c suffix in the current directory and its subdirectories

# find . -name "*.c"

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of What is the usage of find in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn