当前位置:网站首页>Find command – find and search for files

Find command – find and search for files

2022-06-25 05:59:00 ProYuan28

find The command can find a file or directory based on a given path and expression .find There are many parameter options , And support regular , Powerful . In combination with pipes, complex functions can be realized , It is a command that system managers and ordinary users must master .

find Without any parameters , Means to find all files and directories in the current path , If the server load is high, try not to use it during peak hours find command ,find Command fuzzy search still consumes system resources .

Grammar format :find [ Parameters ] [ route ] [ Search and search scope ]

Common parameters

-name Search by name
-size Search by size
-user Search by attributes
-type Search by type
-iname Ignore case

Reference examples

Use -name Parameter view /etc All the .conf Profile at the end :

[[email protected] ~]# find /etc -name "*.conf

Use -size Parameter view /etc Under the directory is greater than 1M The file of :

[[email protected] ~]# find /etc -size +1M

Find all the files in the current user's home directory :

[[email protected] ~]# find $HOME -print

List all files and folders in the current directory and subdirectories :

[[email protected] ~]# find .

stay /home Look in the directory to .txt The ending filename :

[[email protected] ~]# find /home -name "*.txt"

stay /var/log Ignore case in the directory to find .log The ending filename :

[[email protected]xcool ~]# find /var/log -iname "*.log"

Search all files accessed in more than seven days :

[[email protected] ~]# find . -type f -atime +7

Search access time exceeds 10 Minutes of all documents :

[[email protected] ~]# find . -type f -amin +10

find /home Next is not to .txt Final document :

[[email protected] ~]# find /home ! -name "*.txt"
原网站

版权声明
本文为[ProYuan28]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202201251057520.html