当前位置:网站首页>Use the find command
Use the find command
2022-06-22 23:16:00 【Lizexin】
find
effect : It is often used to find files in the system
grammar :
find Lookup location Find type [ What to do after finding ]
Lookup location : Absolute path or relative path
Find type :
-name: Find... By filename
-iname: Find in a case insensitive manner , Only support *?[]^ And so on
-perm: Precise authority search , The mask value of the following permission , The usage of mask value is as follows :
755: lookup 777 Permission file
/222: Look for files where at least one type of user has write permission
/002: Find files that other users have write permission to
-222: Find files that all three types of users have write permission
-user: Find... By user name
-group: Find... By group name
-nogroup: Find files that do not belong to a group
-nouser: Find files that do not belong to the owner
-regex: Match regular expressions to find ,
-iregex: Match regular and ignore case
-type: Find by file type
f: Ordinary documents d: Directory file b: Block device file c: Character device file
l: Link to the file s: Socket character file p: Pipeline files
-size: Find by file size , contain K、M、G Company , A positive number means greater than , A negative number means less than , An integer is equal to
-atime: Find by access days , Positive and negative integers are the same as above
-mtime: Find by data modification days , Positive and negative integers are the same as above
-amin: Find... In minutes of access , Positive and negative integers are the same as above
-mmin: Find by data modification minutes , Positive and negative integers are the same as above
-empty: Find empty file
-follow: Such as find Command encountered symbolic link file , Trace to the file pointed to by the link
-maxdepth: Start from the specified directory and look down several levels of directories
-newer: Find all files that were modified before this file was modified
Handling actions :
-print: Output to the screen , No need to add , Default output to screen
-ls: With ls Long file format output
-delete: Delete the found file
-fls File path : Search the found file with ls The format of detailed information is output to a file
-exec: command {
} \; : Pass the found file to shell Command to process , With this command (|xargs shell command ) Achieve the same purpose
Multiple lookup type connections :
-a: Between two lookup types , Represents and
-o: Between two lookup types , Represents or
!: Before finding the type , Express non , Contrary to the search criteria
example :
1. Find with the ending file name
find /etc/ -name "*.conf"
2. File name ending with ( Ignore case ) Search for
find /etc/ -iname "*.conf"
3. Search by two names , Just match one of the names
find /etc/ -name "*.conf" -o -name "*.txt"
4. Search with regular expressions
find . -regex ".*\(\.txt|\.pdf\)$"
5. Negative condition lookup
find /etc/ ! -name "*.conf"
6. Search by file type , Find all the files in the directory
find /boot/ -type f
7. Find the files from the current directory of the bureau to the two-level directory of the deep level
find /etc/ -maxdepth 2 -type f
8. lookup 7 Files accessed within days
find /etc/type f -atime -7
9. lookup 7 Files accessed the day before yesterday
find /etc/ type -f -atime 7
10. lookup 7 Files accessed at all times before
find /etc/ -type f -atime +7
11. Find all files modified before modifying this file
find /etc/ -type f -newer /etc/fstab
12. Search by file size ,+5k Represents greater than 5k、-5k Represents less than 5k、5k Is equal to 5k
find /etc/ -type f -size +5k
13. Find an empty file and delete it , Three ways :
find /etc/ -empty -delete
find /etc/ -empty -exec rm -rf {
} \;
find /etc/ -empty |xargs rm -rf
14. Find files according to file permissions
find /etc/ -type f -perm 777
15. Find out that the suffix in the directory is php, And permissions are not 755 The file of
find /etc/ -type f -a -name "*.php" -a ! -perm 755
16. Find the log files in the directory , And its existence exceeds 30 God , Copy it to /tmp Under the table of contents
find /var/log/ -name "*.log" -a -mtime +30 -exec cp -rf {
} /tmp \;
边栏推荐
- AutoCAD - five annotation shortcuts
- c# sqlsugar,hisql,freesql orm框架全方位性能测试对比 sqlserver 性能测试
- SSH method 2 for adding node nodes in Jenkins
- Mysql database design
- 2021-01-29
- Relationship between adau1452 development system interface and code data
- Explain the startup process of opengauss multithreading architecture in detail
- C language -- 17 function introduction
- 阻止别人使用浏览器调试
- Spark RDD Programming Guide(2.4.3)
猜你喜欢

2021-08-26

Spark RDD Programming Guide(2.4.3)

C language -- 17 function introduction

Common operations of sourcetree version management

2021-04-14

保证数据库和缓存的一致性

Reasons for the failure of digital transformation and the way to success

MySQL master-slave synchronization and its basic process of database and table division

What are the methods of software stress testing and how to select a software stress testing organization?

Plan and change of continuous repair
随机推荐
Why do you perform performance tests before the software goes online? How to find a software performance testing organization
使用smart-doc自动生成接口文档
R language data preprocessing, converting type variables into factor variables, converting data sets into H2O format, and dividing data sets (training set, test set, verification set)
How to change the dial on the apple Watch
2020-12-20
Spark SQL Generic Load/Save Functions(2.4.3)
R language builds a binary classification model based on H2O package: using H2O GLM constructs regularized logistic regression model and uses H2O AUC value of AUC calculation model
2021-07-27
js读取剪切板的图片
13. 罗马数字转整数
Codeup longest palindrome substring
2020-12-20
eslint 简单配置
2021-08-21
Plan and change of continuous repair
2021-04-14
阻止别人使用浏览器调试
Do domestic mobile phones turn apples? It turned out that it was realized by 100 yuan machine and sharp price reduction
保证数据库和缓存的一致性
2020-12-20